Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PostgreSQL problem: '[' in SQL statement #273

Closed
eliezeralmeida opened this issue Sep 17, 2021 · 6 comments
Closed

PostgreSQL problem: '[' in SQL statement #273

eliezeralmeida opened this issue Sep 17, 2021 · 6 comments
Assignees
Labels

Comments

@eliezeralmeida
Copy link

This not work for me, I did use DappterExtensions.SqlDialect and DappterExtensions.Configure.
I'm using _context.Connection.GetListAsync

dotnet project
image

connection configs
image

Originally posted by @eliezeralmeida in #205 (comment)

@eliezeralmeida
Copy link
Author

Npgsql.PostgresException (0x80004005): 42601: syntax error at or near "["
   at Npgsql.NpgsqlConnector.<ReadMessage>g__ReadMessageLong|194_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()
   at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
   at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
   at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior)
   at Npgsql.NpgsqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
   at Dapper.SqlMapper.ExecuteReaderWithFlagsFallback(IDbCommand cmd, Boolean wasClosed, CommandBehavior behavior) in /_/Dapper/SqlMapper.cs:line 1055
   at Dapper.SqlMapper.QueryImpl[T](IDbConnection cnn, CommandDefinition command, Type effectiveType)+MoveNext() in /_/Dapper/SqlMapper.cs:line 1083
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at DapperExtensions.DapperImplementor.MappColumns[T](IEnumerable`1 values)
   at DapperExtensions.DapperImplementor.GetListAutoMap[T](IDbConnection connection, IList`1 colsToSelect, IClassMapper classMap, IPredicate predicate, IList`1 sort, IDbTransaction transaction, Nullable`1 commandTimeout, Boolean buffered, IList`1 includedProperties)
   at DapperExtensions.DapperImplementor.InternalGetListAutoMap[T](IDbConnection connection, Object predicate, IList`1 sort, IDbTransaction transaction, Nullable`1 commandTimeout, Boolean buffered, IList`1 colsToSelect, IList`1 includedProperties)
   at DapperExtensions.DapperAsyncImplementor.InternalGetListAutoMapAsync[T](IDbConnection connection, Object predicate, IList`1 sort, IDbTransaction transaction, Nullable`1 commandTimeout, Boolean buffered, IList`1 colsToSelect, IList`1 includedProperties)
   at DapperExtensions.DapperAsyncImplementor.GetListAsync[T](IDbConnection connection, Object predicate, IList`1 sort, IDbTransaction transaction, Nullable`1 commandTimeout, Boolean buffered, IList`1 colsToSelect, IList`1 includedProperties)
   at DapperExtensions.DapperAsyncExtensions.GetListAsync[T](IDbConnection connection, Object predicate, IList`1 sort, IDbTransaction transaction, Nullable`1 commandTimeout, Boolean buffered)

@eliezeralmeida
Copy link
Author

news...

GetListAsync not work.
GetList works.

@valfrid-ly
Copy link
Collaborator

I'm gonna check this @eliezeralmeida . Both should work

@valfrid-ly valfrid-ly self-assigned this Sep 17, 2021
@valfrid-ly valfrid-ly added the bug label Sep 17, 2021
@abukhalid-abdurrahman
Copy link

Npgsql.PostgresException (0x80004005): 42601: syntax error at or near "["
   at Npgsql.NpgsqlConnector.<ReadMessage>g__ReadMessageLong|194_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()
   at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
   at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
   at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior)
   at Npgsql.NpgsqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
   at Dapper.SqlMapper.ExecuteReaderWithFlagsFallback(IDbCommand cmd, Boolean wasClosed, CommandBehavior behavior) in /_/Dapper/SqlMapper.cs:line 1055
   at Dapper.SqlMapper.QueryImpl[T](IDbConnection cnn, CommandDefinition command, Type effectiveType)+MoveNext() in /_/Dapper/SqlMapper.cs:line 1083
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at DapperExtensions.DapperImplementor.MappColumns[T](IEnumerable`1 values)
   at DapperExtensions.DapperImplementor.GetListAutoMap[T](IDbConnection connection, IList`1 colsToSelect, IClassMapper classMap, IPredicate predicate, IList`1 sort, IDbTransaction transaction, Nullable`1 commandTimeout, Boolean buffered, IList`1 includedProperties)
   at DapperExtensions.DapperImplementor.InternalGetListAutoMap[T](IDbConnection connection, Object predicate, IList`1 sort, IDbTransaction transaction, Nullable`1 commandTimeout, Boolean buffered, IList`1 colsToSelect, IList`1 includedProperties)
   at DapperExtensions.DapperAsyncImplementor.InternalGetListAutoMapAsync[T](IDbConnection connection, Object predicate, IList`1 sort, IDbTransaction transaction, Nullable`1 commandTimeout, Boolean buffered, IList`1 colsToSelect, IList`1 includedProperties)
   at DapperExtensions.DapperAsyncImplementor.GetListAsync[T](IDbConnection connection, Object predicate, IList`1 sort, IDbTransaction transaction, Nullable`1 commandTimeout, Boolean buffered, IList`1 colsToSelect, IList`1 includedProperties)
   at DapperExtensions.DapperAsyncExtensions.GetListAsync[T](IDbConnection connection, Object predicate, IList`1 sort, IDbTransaction transaction, Nullable`1 commandTimeout, Boolean buffered)

image

Because of the generated SQL query, PostgreSQL does not support this syntax.

This was referenced Dec 19, 2021
@marceln
Copy link

marceln commented Jan 14, 2022

Same happens to me, although I explicitly set the dialect. Any news on a fix or workaround?

@valfrid-ly
Copy link
Collaborator

What I could notice is the error is in Async method and the settings are being made to DapperExtensions and not to DapperAsyncExtensions.

DapperAsyncExtensions is using a default Dialect to SqlServer instead of the one from the configuration as Sync methods come from DapperExtensions and AsyncMethods comes from DapperAsyncExtensions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants