Skip to content

Invalid table name in queries #238

@dschoschu

Description

@dschoschu
Q A
auditor version 3.3.2
PHP version 8.2
Database PostgreSQL

Summary

In #196 the generation of tables names for the doctrine migrations were fixed. But the issue continues to exist in the viewer and when trying to insert audit data.

Wenn editing an entity:

doctrine.DEBUG: Executing statement: INSERT INTO "user"_audit (type, object_id, discriminator, transaction_hash, diffs, blame_id, blame_user, blame_user_fqdn, blame_user_firewall, ip, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) (parameters: array{"1":"update","2":"0192f730-c971-70b0-b08b-4ede7b9e80e8","3":null,"4":"df03e9ca59a2efdd26721e4854be68e7a2b5bdc2 ....

When opening the viewer for an entity with double quotes:

[2025-01-16T12:43:45.094318+01:00] request.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\SyntaxErrorException: "An exception occurred while executing a query: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "at" LINE 1: SELECT * FROM "user"_audit at ORDER BY created_at DESC, id D... ^" at ExceptionConverter.php line 62 {"exception":"[object] (Doctrine\DBAL\Exception\SyntaxErrorException(code: 7): An exception occurred while executing a query: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "at"\nLINE 1: SELECT * FROM "user"_audit at ORDER BY created_at DESC, id D...\n ^ at /var/www/html/app/vendor/doctrine/dbal/src/Driver/API/PostgreSQL/ExceptionConverter.php:62)\n[previous exception] [object] (Doctrine\DBAL\Driver\PDO\Exception(code: 7): SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "at"\nLINE 1: SELECT * FROM "user"_audit at ORDER BY created_at DESC, id D...\n ^ at /var/www/html/app/vendor/doctrine/dbal/src/Driver/PDO/Exception.php:28)\n[previous exception] [object] (PDOException(code: 42601): SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "at"\nLINE 1: SELECT * FROM "user"_audit at ORDER BY created_at DESC, id D...\n ^ at /var/www/html/app/vendor/doctrine/dbal/src/Driver/PDO/Connection.php:57)"}

Current behavior

No audit data is inserted for entity with special names and the viewer for these entites throws an exception when accessing it.

How to reproduce

Edit an entity with a special name like user or open the viewer for such an entity.

Expected behavior

Audit data is inserted and the viewer is accessible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions