Giter Club home page Giter Club logo

Comments (5)

benpaxton-hf avatar benpaxton-hf commented on May 27, 2024

Example failing test:

diff --git a/builder_insert_test.go b/builder_insert_test.go
index 5ea8662..ef3db52 100644
--- a/builder_insert_test.go
+++ b/builder_insert_test.go
@@ -15,6 +15,10 @@ func TestBuilderInsert(t *testing.T) {
        assert.NoError(t, err)
        assert.EqualValues(t, "INSERT INTO table1 (c,d) Values (1,2)", sql)
 
+       sql, err = Insert(Eq{"e": 3}, Eq{"c": 1}, Eq{"d": 2}).Into("table1").ToBoundSQL()
+       assert.NoError(t, err)
+       assert.EqualValues(t, "INSERT INTO table1 (c,d,e) Values (1,2,3)", sql)
+
        sql, err = Insert(Eq{"c": 1, "d": Expr("SELECT b FROM t WHERE d=? LIMIT 1", 2)}).Into("table1").ToBoundSQL()
        assert.NoError(t, err)
        assert.EqualValues(t, "INSERT INTO table1 (c,d) Values (1,(SELECT b FROM t WHERE d=2 LIMIT 1))", sql)
$ go test -v -run TestBuilderInsert
=== RUN   TestBuilderInsert
--- FAIL: TestBuilderInsert (0.00s)
    builder_insert_test.go:20: 
        	Error Trace:	builder_insert_test.go:20
        	Error:      	Not equal: 
        	            	expected: "INSERT INTO table1 (c,d,e) Values (1,2,3)"
        	            	actual  : "INSERT INTO table1 (c,d,e) Values (1,3,2)"
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1 +1 @@
        	            	-INSERT INTO table1 (c,d,e) Values (1,2,3)
        	            	+INSERT INTO table1 (c,d,e) Values (1,3,2)
        	Test:       	TestBuilderInsert
FAIL
exit status 1
FAIL	github.com/go-xorm/builder	0.006s

from builder.

miketonks avatar miketonks commented on May 27, 2024

This seems quite a serious bug for us. We have pinned to 0.3.1 but would be nice to fix.

Options seem to be to either remove the sort or fix it. If you indicate which option is preferred or other issues to consider, we could work on a PR.

from builder.

BetaCat0 avatar BetaCat0 commented on May 27, 2024

@benpaxton-hf Thanks for reporting!

from builder.

BetaCat0 avatar BetaCat0 commented on May 27, 2024

@miketonks Thank you for reporting and you can make a PR to fix it. 😄

from builder.

lunny avatar lunny commented on May 27, 2024

@benpaxton-hf @miketonks @BetaCat0 #42 will resolve this issue, please confirm.

from builder.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.