Npgsql.PostgresException syntax error at or near "["
See original GitHub issueHello @JordanMarr,
in our project we are moving away from SQLServer to go to PostgreSQL.
I installed SqlHydra.Npgsql
tool and generated the new database files.
I also installed Npgsql and removed the System.Data.SqlClient library.
My project is now compiling how when running the tests I get the following error:
System.AggregateException: One or more errors occurred. (42601: syntax error at or near "["
POSITION: 13)
---> Npgsql.PostgresException (0x80004005): 42601: syntax error at or near "["
POSITION: 13
at Npgsql.Internal.NpgsqlConnector.<ReadMessage>g__ReadMessageLong|225_0(NpgsqlConnector connector, Boolean async, DataRowLoadingMode dataRowLoadingMode, Boolean readingNotifications, Boolean isReadingPrependedMessage)
at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)
at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)
at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlCommand.ExecuteNonQuery(Boolean async, CancellationToken cancellationToken)
Exception data:
Severity: ERROR
SqlState: 42601
MessageText: syntax error at or near "["
Position: 13
File: scan.l
Line: 1176
Routine: scanner_yyerror
--- End of inner exception stack trace ---
I feel like the [
syntax error is because the generated SQL is for SQLServer instead of PostgreSQL.
The query which trigger the error is:
deleteAsync (Shared ctx) {
for _ in table<dbo.EncounterForms> do
deleteAll
}
Is there something I am missing? Is it possible to see the generated SQL by SQL Hydra to try understand the problem?
Issue Analytics
- State:
- Created 8 months ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
PostgreSQL, Npgsql returning 42601: syntax error at or ...
I'm trying to use Npgsql and/or Dapper to query a table and I keep running into Npgsql.PostgresException 42601: syntax error at or near...
Read more >42601: syntax error at or near "[" · Issue #404 · npgsql ...
Ran into this error message while trying to perform dotnet ef database ... Npgsql.PostgresException: 42601: syntax error at or near "[" #404.
Read more >PostgreSQL error 42601- How we fix it
PostgreSQL error 42601 mainly occurs due to the syntax errors in the code. Proper syntax check and code correction will fix it up....
Read more >Class PostgresException | Npgsql Documentation
Class PostgresException. The exception that is thrown when the PostgreSQL backend reports errors (e.g. query SQL issues, constraint violations).
Read more >ERROR: syntax error at or near "END" [closed]
I thought it has to be with schema since you can see below the the table has a schema name of public so...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Oh…
I forgot to change
SqlKata.Compilers.SqlServerCompiler()
toSqlKata.Compilers.PostgresCompiler()
.Got bitten once again by the
openContext
function 😅I haven’t tried that specifically, but i don’t see any reason why it wouldn’t work since the array types are not hardcoded.