Comments (5)
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.
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.
@benpaxton-hf Thanks for reporting!
from builder.
@miketonks Thank you for reporting and you can make a PR to fix it. 😄
from builder.
@benpaxton-hf @miketonks @BetaCat0 #42 will resolve this issue, please confirm.
from builder.
Related Issues (15)
- Insert: sort column names HOT 1
- Proposal: quote column names HOT 5
- how to build sql with limit and order by HOT 3
- Postgres complaining about parameters HOT 2
- Struct to sql query for create table
- Why `Builder.limitWriteTo` erase limit condition? HOT 3
- Create SQL by builder and populate struct slice HOT 1
- Insert argument wrong order HOT 3
- Add `GroupBy` HOT 1
- How to use Mysql's "regexp" or postgresql's "~*" ? HOT 1
- ToBoundSQL函数 不能过滤参数防止SQL注入吗? HOT 6
- Cond interface needs iterator
- Feature request: support subquery as a condition value HOT 4
- how to use builder with xorm HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from builder.