Skip to content

Conversation

@hmgle
Copy link
Contributor

@hmgle hmgle commented Feb 25, 2017

usage:
places := []*Place{&place1, &place2}
db.NamedExec("INSERT INTO place (country, telcode) VALUES (:country, :telcode)", places)

usage:
places := []*Place{&place1, &place2}
db.NamedExec("INSERT INTO place (country, telcode) VALUES (:country, :telcode)", places)
@dcormier
Copy link

I would be great to see this added and close #238.

@dcormier dcormier mentioned this pull request Aug 10, 2018
@AndyEsser
Copy link

Would also be very useful for us

@branch-divy
Copy link

+1

@venkateshthallam
Copy link

+1. We could really use this.

@aceyin
Copy link

aceyin commented Sep 7, 2018

when this feature will be released ?

mfateev pushed a commit to mfateev/sqlx that referenced this pull request Sep 10, 2018
@Seklfreak
Copy link

+1 would be very useful

@kohpai
Copy link

kohpai commented Oct 23, 2018

Would be a great feature to have

@mfateev
Copy link

mfateev commented Oct 23, 2018

+1. Waiting on this. In the meantime I have to use a private fork :(.

@mCloud
Copy link

mCloud commented Nov 17, 2018

++

@xurwxj
Copy link

xurwxj commented Nov 19, 2018

+1

1 similar comment
@safety-tom
Copy link

+1

@ivanovaleksey
Copy link

@jmoiron Hi, do you have any plans for this feature?

@god1dog
Copy link

god1dog commented Nov 25, 2018

we waiting this feature!

@pawanrawal
Copy link

Can we please at least know if there is something else needed to get this merged @jmoiron?

@matyunin
Copy link

matyunin commented Dec 6, 2018

Waiting for merge PLZ 🙏

1 similar comment
@TomohiroYamada
Copy link

Waiting for merge PLZ 🙏

@renskiy
Copy link

renskiy commented Dec 27, 2018

@hmgle this is great feature but it missed some tests, do you have plans to add them?

@arushijn
Copy link

+1 need this feature

@polym
Copy link

polym commented Feb 18, 2019

+1

@GnatorX
Copy link

GnatorX commented Feb 20, 2019

+1 any update on merging this feature?

@ductm54
Copy link

ductm54 commented Feb 27, 2019

+1

1 similar comment
@tonyOreglia
Copy link

+1

@gayanhewa
Copy link

Is this likely to get merged? Or is the approach recommended by @tanishiking in #238 the recommended way to go?

@jmoiron
Copy link
Owner

jmoiron commented Mar 12, 2019

I like this approach, I will merge it and bump version on sqlx as soon as I can look over this and test it.

@gayanhewa
Copy link

@jmoiron Awesome, can lend a hand with the testing if required.

@gayanhewa
Copy link

gayanhewa commented Mar 21, 2019

This is how I used it with NamedExec, not much different.

        processedTxns := []*salesTxn{}
        // append a bunch
        // ...

	if len(processedTxns) > 0 {
		tx := pulseDB.MustBegin()
		sql = "INSERT INTO sales_transactions(id, company_id, mobileuser_id) VALUES (:id, :company_id, :mobileuser_id)"
		if _, err := tx.NamedExec(sql, processedTxns); err != nil {
			fmt.Printf("Failed updating sales transactions for mobileuser %s \n", m.ID)
			log.Println(err)
		}
		tx.Commit()
	}

@cgebe
Copy link

cgebe commented Apr 4, 2019

I had problems passing a list of referenced structs which caused sqlx to insert only 1 record without error. Passing non-referenced structs works as usual. I used a local SQLite DB.

@hejiaji
Copy link

hejiaji commented May 6, 2019

@jmoiron Is this feature going to be published with a tag on anytime soon?

@smartfly
Copy link

good function

@WiredTombstone
Copy link

WiredTombstone commented Jun 16, 2019

Unfortunately I get this error: Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1.

Does anyone have a recommendation for debugging this? (The SQL does work if I do a for over the records and execute it individually, but does not work if I pass all the records).

Looking into it a bit it might be because my Insert statement looks like this:

INSERT INTO table (IP) VALUES (INET6_ATON(:IP))

Edit Update: Altering the regex on line 213 of named.go to be ([^(]?+[^)].) seems to resolve my issue, though it may not be advisable as a patch for everyone.

@valclark1
Copy link

When is this going to be released? I tried using it in 1.2.0 but I keep getting a Mapping slice error.

@gosom
Copy link

gosom commented Aug 21, 2019

Also using 1.2.0 and getting the same
jmoiron/sqlx/reflectx.(*Mapper).TraversalsByNameFunc on slice Value

@un000
Copy link

un000 commented Sep 7, 2019

the same @jmoiron

@haynesherway
Copy link

same

@griddyphillip
Copy link

also here @jmoiron

@griddyphillip
Copy link

for anybody looking for a hotfix, it's likely that your go.mod isn't pointing to the master branch and pointed to v1.2.0

try running go get github.com/jmoiron/sqlx@master to fix this

@franzwilhelm
Copy link

Still getting the slice value error on master with postgres

@sepbot
Copy link

sepbot commented Dec 5, 2019

Doesn't seem to work when slice values are map[string]interface{}, it wants struct

@coolyrat
Copy link

coolyrat commented Mar 1, 2020

hoping to release soon

@tshubham7
Copy link

after doing this
go get github.com/jmoiron/sqlx@master
I can insert multiple records at one time, thanks

@dmngu9
Copy link

dmngu9 commented Aug 3, 2020

do you have example on how to do batch insert ?

@dcormier
Copy link

dcormier commented Aug 3, 2020

@dmngu9 The example is in the opening comment on this PR. Just scroll to the top.

@dmitrychopey
Copy link

Hello. When are you planing to release this feature?

@riptl
Copy link

riptl commented Dec 13, 2020

@dmitrychopey If you need this and don't want to wait for a release, use go get github.com/jmoiron/sqlx@master to tell Go to use the latest commit.

@MarceloVano
Copy link

is it broken? I'm facing the same issue with latest commit, version v1.3.4-0.20210409010340-1810e7a2e72d

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.