Skip to content

Named parameters for MySQL inserts / updates #3037

Closed

Description

@SebastienMelki

What do you want to change?

I'm trying to generate code based on queries like this

-- name: InsertPurchaseGuid :exec INSERT INTO purchase_guids (external_id, guid, created_at, updated_at, partner_id, payment_method_id) VALUES (:external_id, :guid, :created_at, :updated_at, :partner_id, :payment_method_id);

So that I can use the NamedExec function of the mysql driver. But whenever I run sqlc generate I get this error

db/queries/subs/insert_purchase_guid.sql:3:10: syntax error near ":external_id, :guid, :created_at, :updated_at, :partner_id, :payment_method_id);"

Is this not supported at all? Or am I doing it wrong?

Thank you!

What database engines need to be changed?

MySQL

What programming language backends need to be changed?

Go

Activity

  1. orisano commented on Dec 5, 2023

    @orisano
    Contributor

    MySQL does not support NamedParameter

  2. SebastienMelki commented on Dec 5, 2023

    @SebastienMelki
    Author

    MySQL does not support NamedParameter

    Hello, do you mean it's not supported in sqlc? Because MySQL itself does support named parameters just fine as far as my testing goes. I used the .NamedExec of the sql driver in go, and got the expected results

  3. removed
    enhancementNew feature or request
    triageNew issues that hasn't been reviewed
    on Dec 5, 2023
  4. locked and limited conversation to collaborators on Dec 5, 2023
  5. converted this issue into a discussion #3038 on Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions