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

Fix dapper example #186

Merged
merged 1 commit into from
Sep 16, 2024
Merged

Conversation

molostovvs
Copy link
Contributor

Parameters with the $ prefix are currently not supported, so we need to fix the example.

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

At the moment the example for dapper uses parameters with the prefix $, which is currently unsupported and causes an error when executing the request.

What is the new behavior?

The corrected example uses the @ prefix for parameters, which is supported by sdk.

Other information

At the moment (sdk 0.7.0) a simple query made using an example like:

await connection.ExecuteAsync(
    "insert into items (addtime, name) values (@AddTime, @ItemName)",
    new { AddTime = DateTime.UtcNow, ItemName = item });

results in an error:

{"errorMessage":"Status: GenericError, Issues:\n[0] (:1:43)Error: Unknown name: $AddTime\n","errorType":"YdbException","stackTrace":"   at Ydb.Sdk.Ado.YdbDataReader.NextExecPart()\n   at Ydb.Sdk.Ado.YdbDataReader.Init()\n   at Ydb.Sdk.Ado.YdbDataReader.CreateYdbDataReader(IAsyncEnumerator\u00601 resultSetStream, Action\u00601 onStatus, YdbTransaction ydbTransaction)\n   at Ydb.Sdk.Ado.YdbCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)\n   at Ydb.Sdk.Ado.YdbCommand.ExecuteReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)\n   at Ydb.Sdk.Ado.YdbCommand.ExecuteNonQueryAsync(CancellationToken cancellationToken)\n   at Dapper.SqlMapper.ExecuteImplAsync(IDbConnection cnn, CommandDefinition command, Object param) in /_/Dapper/SqlMapper.Async.cs:line 662\n   at Bot.Commands.AddCommand.ExecuteAsync(ITelegramBotClient bot, Int64 chatId, DbConnection connection) in /home/mvs/source/playground/tg-bot/src/Bot/Commands/AddCommand.cs:line 15\n   at Bot.Handler.FunctionHandler(Request request) in /home/mvs/source/playground/tg-bot/src/Bot/Handler.cs:line 53\n   at CallSite.Target(Closure, CallSite, Object)\n   at Yandex.Cloud.Runtime.DefaultRuntime.Start() in /bootstrap/runtime/DefaultRuntime.cs:line 57\ninner:\n"}

parameters with the $ prefix are currently not supported, so we need to fix the example
@KirillKurdyukov KirillKurdyukov enabled auto-merge (squash) September 16, 2024 11:44
Copy link
Collaborator

@KirillKurdyukov KirillKurdyukov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. The example won't work for the latest version, but it's not about the parameter.

@KirillKurdyukov KirillKurdyukov merged commit 6a4d4d2 into ydb-platform:main Sep 16, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants