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

Batch insert using map seems to still not work #701

Closed
saantiaguilera opened this issue Feb 18, 2021 · 3 comments
Closed

Batch insert using map seems to still not work #701

saantiaguilera opened this issue Feb 18, 2021 · 3 comments

Comments

@saantiaguilera
Copy link

Hi, I'm using the master branch since it has the fix of batch inserts on named arguments. Still, when using a map it seems to still fail:

_, err := tx.NamedExec(
    "INSERT INTO state (state_id, name, created_at) VALUES (:id, :name, :time) ON DUPLICATE KEY UPDATE state_id=state_id",
    []map[string]interface{}{
        {"id": "MX-MEX", "name": "Ciudad de México", "time": time.Now()},
	{"id": "BR-SP", "name": "São Paulo", "time": time.Now()},
    },
)

Seems to fail with error: sql: expected 3 arguments, got 6

Any idea why?

@hyperhtml
Copy link

hyperhtml commented Feb 21, 2021

Nothing to add here, but I just ran into this exact issue as well.

I can get the above query to run if you omit ON DUPLICATE KEY UPDATE state_id=state_id. However, I also need that same clause in my query.

Edit: Just noticed there are a couple of other issues relating to this:
#694

@alexshtin
Copy link

I have same issue. Pinned to 1.2.0 for now.

@jmoiron
Copy link
Owner

jmoiron commented May 15, 2021

Hesitantly going to call this fixed with #734, which is tagged with 1.3.4

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

No branches or pull requests

4 participants