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

Dialect not honored for Insert #130

Closed
marshall-mcmullen opened this issue Aug 14, 2019 · 5 comments
Closed

Dialect not honored for Insert #130

marshall-mcmullen opened this issue Aug 14, 2019 · 5 comments

Comments

@marshall-mcmullen
Copy link
Contributor

marshall-mcmullen commented Aug 14, 2019

First, I want to thank you for goqu. It's fantastic and I'm loving it so far!

I think I found an issue with Insert not honoring the dialect setting for the placeholders. The simplest test to exhibit this is the following:

func TestInsertDialect(t *testing.T) {

    dialect := goqu.Dialect("postgres")

    var value1, value2 int 

    insertDataset := dialect.Insert("foo").Prepared(true).Rows(goqu.Record{
        "value1": value1,
        "value2": value2,
    })  

    sql, _, _ := insertDataset.ToSQL()
    assert.Equal(t, `INSERT INTO "foo" ("value1", "value2") VALUES ($1, $2)`, sql)
}

The test fails with the following output:

    user_test.go:81: 
        	Error Trace:	user_test.go:81
        	Error:      	Not equal: 
        	            	expected: "INSERT INTO \"foo\" (\"value1\", \"value2\") VALUES ($1, $2)"
        	            	actual  : "INSERT INTO \"foo\" (\"value1\", \"value2\") VALUES (?, ?)"
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1 +1 @@
        	            	-INSERT INTO "foo" ("value1", "value2") VALUES ($1, $2)
        	            	+INSERT INTO "foo" ("value1", "value2") VALUES (?, ?)
        	Test:       	TestInsertDialect
@doug-martin
Copy link
Owner

This is most likely related to #126 i don't think I'll have time until Friday or Saturday to look at this.

@marshall-mcmullen
Copy link
Contributor Author

Thanks for the super fast response @doug-martin ! That PR does look very related. I tried to trace through the code to figure out if I was doing something wrong but I didn't get far enough to sort it all out. I'll work around this locally for now until you have time to get this resolved.

Thanks again for the awesome work and super responsiveness.

@doug-martin
Copy link
Owner

I just published v8.3.1 which includes #126

Thanks for the bug report and let me know if you are still having issues!

@marshall-mcmullen
Copy link
Contributor Author

@doug-martin woohoo! Thank you so much for getting this merged. I will pick up the latest version and try it out tonight and update this bug with my results. Can't wait!

@marshall-mcmullen
Copy link
Contributor Author

@doug-martin I upgraded to v8.3.1 and the problem is fixed! Thank you so much for your super quick turnaround on this bug as it was driving me crazy. Awesome job.

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

No branches or pull requests

2 participants