Additional documentation.

This commit is contained in:
go-jet 2019-07-18 17:43:11 +02:00
parent d253a35161
commit b10270b502
48 changed files with 892 additions and 699 deletions

View file

@ -229,7 +229,7 @@ func TestFloatOperators(t *testing.T) {
CEIL(AllTypes.Real),
FLOOR(AllTypes.Real),
ROUND(AllTypes.Decimal),
ROUND(AllTypes.Decimal, Int(3)).AS("round"),
ROUND(AllTypes.Decimal, AllTypes.Integer).AS("round"),
SIGN(AllTypes.Real),
TRUNC(AllTypes.Decimal),
TRUNC(AllTypes.Decimal, Int(1)),
@ -361,7 +361,7 @@ func TestSubQueryColumnReference(t *testing.T) {
args []interface{}
}
subQueries := map[ExpressionTable]expected{}
subQueries := map[SelectTable]expected{}
selectSubQuery := AllTypes.SELECT(
AllTypes.Boolean,
@ -378,7 +378,7 @@ func TestSubQueryColumnReference(t *testing.T) {
LIMIT(2).
AsTable("subQuery")
var selectExpectedSql = ` (
var selectexpectedSQL = ` (
SELECT all_types.boolean AS "all_types.boolean",
all_types.integer AS "all_types.integer",
all_types.real AS "all_types.real",
@ -424,7 +424,7 @@ func TestSubQueryColumnReference(t *testing.T) {
).
AsTable("subQuery")
unionExpectedSql := `
unionexpectedSQL := `
(
(
SELECT all_types.boolean AS "all_types.boolean",
@ -458,8 +458,8 @@ func TestSubQueryColumnReference(t *testing.T) {
)
) AS "subQuery"`
subQueries[selectSubQuery] = expected{sql: selectExpectedSql, args: []interface{}{int64(2)}}
subQueries[unionSubQuery] = expected{sql: unionExpectedSql, args: []interface{}{int64(1), int64(1), int64(1)}}
subQueries[selectSubQuery] = expected{sql: selectexpectedSQL, args: []interface{}{int64(2)}}
subQueries[unionSubQuery] = expected{sql: unionexpectedSQL, args: []interface{}{int64(1), int64(1), int64(1)}}
for subQuery, expected := range subQueries {
boolColumn := AllTypes.Boolean.From(subQuery)
@ -487,7 +487,7 @@ func TestSubQueryColumnReference(t *testing.T) {
).
FROM(subQuery)
var expectedSql = `
var expectedSQL = `
SELECT "subQuery"."all_types.boolean" AS "all_types.boolean",
"subQuery"."all_types.integer" AS "all_types.integer",
"subQuery"."all_types.real" AS "all_types.real",
@ -500,7 +500,7 @@ SELECT "subQuery"."all_types.boolean" AS "all_types.boolean",
"subQuery"."aliasedColumn" AS "aliasedColumn"
FROM`
assertStatementSql(t, stmt1, expectedSql+expected.sql+";\n", expected.args...)
assertStatementSql(t, stmt1, expectedSQL+expected.sql+";\n", expected.args...)
dest1 := []model.AllTypes{}
err := stmt1.Query(db, &dest1)
@ -523,7 +523,7 @@ FROM`
//fmt.Println(stmt2.DebugSql())
assertStatementSql(t, stmt2, expectedSql+expected.sql+";\n", expected.args...)
assertStatementSql(t, stmt2, expectedSQL+expected.sql+";\n", expected.args...)
dest2 := []model.AllTypes{}
err = stmt2.Query(db, &dest2)

View file

@ -11,7 +11,7 @@ import (
func TestDeleteWithWhere(t *testing.T) {
initForDeleteTest(t)
var expectedSql = `
var expectedSQL = `
DELETE FROM test_sample.link
WHERE link.name IN ('Gmail', 'Outlook');
`
@ -19,14 +19,14 @@ WHERE link.name IN ('Gmail', 'Outlook');
DELETE().
WHERE(Link.Name.IN(String("Gmail"), String("Outlook")))
assertStatementSql(t, deleteStmt, expectedSql, "Gmail", "Outlook")
assertStatementSql(t, deleteStmt, expectedSQL, "Gmail", "Outlook")
assertExec(t, deleteStmt, 2)
}
func TestDeleteWithWhereAndReturning(t *testing.T) {
initForDeleteTest(t)
var expectedSql = `
var expectedSQL = `
DELETE FROM test_sample.link
WHERE link.name IN ('Gmail', 'Outlook')
RETURNING link.id AS "link.id",
@ -39,7 +39,7 @@ RETURNING link.id AS "link.id",
WHERE(Link.Name.IN(String("Gmail"), String("Outlook"))).
RETURNING(Link.AllColumns)
assertStatementSql(t, deleteStmt, expectedSql, "Gmail", "Outlook")
assertStatementSql(t, deleteStmt, expectedSQL, "Gmail", "Outlook")
dest := []model.Link{}

View file

@ -11,7 +11,7 @@ import (
func TestInsertValues(t *testing.T) {
cleanUpLinkTable(t)
var expectedSql = `
var expectedSQL = `
INSERT INTO test_sample.link (id, url, name, description) VALUES
(100, 'http://www.postgresqltutorial.com', 'PostgreSQL Tutorial', DEFAULT),
(101, 'http://www.google.com', 'Google', DEFAULT),
@ -28,7 +28,7 @@ RETURNING link.id AS "link.id",
VALUES(102, "http://www.yahoo.com", "Yahoo", nil).
RETURNING(Link.AllColumns)
assertStatementSql(t, insertQuery, expectedSql,
assertStatementSql(t, insertQuery, expectedSQL,
100, "http://www.postgresqltutorial.com", "PostgreSQL Tutorial",
101, "http://www.google.com", "Google",
102, "http://www.yahoo.com", "Yahoo", nil)
@ -74,7 +74,7 @@ RETURNING link.id AS "link.id",
func TestInsertEmptyColumnList(t *testing.T) {
cleanUpLinkTable(t)
expectedSql := `
expectedSQL := `
INSERT INTO test_sample.link VALUES
(100, 'http://www.postgresqltutorial.com', 'PostgreSQL Tutorial', DEFAULT);
`
@ -82,7 +82,7 @@ INSERT INTO test_sample.link VALUES
stmt := Link.INSERT().
VALUES(100, "http://www.postgresqltutorial.com", "PostgreSQL Tutorial", DEFAULT)
assertStatementSql(t, stmt, expectedSql,
assertStatementSql(t, stmt, expectedSQL,
100, "http://www.postgresqltutorial.com", "PostgreSQL Tutorial")
assertExec(t, stmt, 1)
@ -90,7 +90,7 @@ INSERT INTO test_sample.link VALUES
func TestInsertModelObject(t *testing.T) {
cleanUpLinkTable(t)
var expectedSql = `
var expectedSQL = `
INSERT INTO test_sample.link (url, name) VALUES
('http://www.duckduckgo.com', 'Duck Duck go');
`
@ -104,7 +104,7 @@ INSERT INTO test_sample.link (url, name) VALUES
INSERT(Link.URL, Link.Name).
MODEL(linkData)
assertStatementSql(t, query, expectedSql, "http://www.duckduckgo.com", "Duck Duck go")
assertStatementSql(t, query, expectedSQL, "http://www.duckduckgo.com", "Duck Duck go")
result, err := query.Exec(db)
@ -116,7 +116,7 @@ INSERT INTO test_sample.link (url, name) VALUES
}
func TestInsertModelsObject(t *testing.T) {
expectedSql := `
expectedSQL := `
INSERT INTO test_sample.link (url, name) VALUES
('http://www.postgresqltutorial.com', 'PostgreSQL Tutorial'),
('http://www.google.com', 'Google'),
@ -142,7 +142,7 @@ INSERT INTO test_sample.link (url, name) VALUES
INSERT(Link.URL, Link.Name).
MODELS([]model.Link{tutorial, google, yahoo})
assertStatementSql(t, stmt, expectedSql,
assertStatementSql(t, stmt, expectedSQL,
"http://www.postgresqltutorial.com", "PostgreSQL Tutorial",
"http://www.google.com", "Google",
"http://www.yahoo.com", "Yahoo")
@ -151,7 +151,7 @@ INSERT INTO test_sample.link (url, name) VALUES
}
func TestInsertUsingMutableColumns(t *testing.T) {
var expectedSql = `
var expectedSQL = `
INSERT INTO test_sample.link (url, name, description) VALUES
('http://www.postgresqltutorial.com', 'PostgreSQL Tutorial', DEFAULT),
('http://www.google.com', 'Google', NULL),
@ -175,7 +175,7 @@ INSERT INTO test_sample.link (url, name, description) VALUES
MODEL(google).
MODELS([]model.Link{google, yahoo})
assertStatementSql(t, stmt, expectedSql,
assertStatementSql(t, stmt, expectedSQL,
"http://www.postgresqltutorial.com", "PostgreSQL Tutorial",
"http://www.google.com", "Google", nil,
"http://www.google.com", "Google", nil,
@ -190,7 +190,7 @@ func TestInsertQuery(t *testing.T) {
Exec(db)
assert.NilError(t, err)
var expectedSql = `
var expectedSQL = `
INSERT INTO test_sample.link (url, name) (
SELECT link.url AS "link.url",
link.name AS "link.name"
@ -212,7 +212,7 @@ RETURNING link.id AS "link.id",
).
RETURNING(Link.AllColumns)
assertStatementSql(t, query, expectedSql, int64(0))
assertStatementSql(t, query, expectedSQL, int64(0))
dest := []model.Link{}

View file

@ -72,7 +72,7 @@ FROM test_sample.person;
func TestSelecSelfJoin1(t *testing.T) {
var expectedSql = `
var expectedSQL = `
SELECT employee.employee_id AS "employee.employee_id",
employee.first_name AS "employee.first_name",
employee.last_name AS "employee.last_name",
@ -97,7 +97,7 @@ ORDER BY employee.employee_id;
).
ORDER_BY(Employee.EmployeeID)
assertStatementSql(t, query, expectedSql)
assertStatementSql(t, query, expectedSQL)
type Manager model.Employee

View file

@ -10,7 +10,7 @@ import (
)
func TestSelect_ScanToStruct(t *testing.T) {
expectedSql := `
expectedSQL := `
SELECT DISTINCT actor.actor_id AS "actor.actor_id",
actor.first_name AS "actor.first_name",
actor.last_name AS "actor.last_name",
@ -24,7 +24,7 @@ WHERE actor.actor_id = 1;
DISTINCT().
WHERE(Actor.ActorID.EQ(Int(1)))
assertStatementSql(t, query, expectedSql, int64(1))
assertStatementSql(t, query, expectedSQL, int64(1))
actor := model.Actor{}
err := query.Query(db, &actor)
@ -42,7 +42,7 @@ WHERE actor.actor_id = 1;
}
func TestClassicSelect(t *testing.T) {
expectedSql := `
expectedSQL := `
SELECT payment.payment_id AS "payment.payment_id",
payment.customer_id AS "payment.customer_id",
payment.staff_id AS "payment.staff_id",
@ -74,7 +74,7 @@ LIMIT 30;
ORDER_BY(Payment.PaymentID.ASC()).
LIMIT(30)
assertStatementSql(t, query, expectedSql, int64(30))
assertStatementSql(t, query, expectedSQL, int64(30))
dest := []model.Payment{}
@ -85,7 +85,7 @@ LIMIT 30;
}
func TestSelect_ScanToSlice(t *testing.T) {
expectedSql := `
expectedSQL := `
SELECT customer.customer_id AS "customer.customer_id",
customer.store_id AS "customer.store_id",
customer.first_name AS "customer.first_name",
@ -103,7 +103,7 @@ ORDER BY customer.customer_id ASC;
query := Customer.SELECT(Customer.AllColumns).ORDER_BY(Customer.CustomerID.ASC())
assertStatementSql(t, query, expectedSql)
assertStatementSql(t, query, expectedSQL)
err := query.Query(db, &customers)
assert.NilError(t, err)
@ -116,7 +116,7 @@ ORDER BY customer.customer_id ASC;
}
func TestSelectAndUnionInProjection(t *testing.T) {
expectedSql := `
expectedSQL := `
SELECT payment.payment_id AS "payment.payment_id",
(
SELECT customer.customer_id AS "customer.customer_id"
@ -156,12 +156,12 @@ LIMIT 12;
).
LIMIT(12)
assertStatementSql(t, query, expectedSql, int64(1), int64(1), int64(10), int64(1), int64(2), int64(1), int64(12))
assertStatementSql(t, query, expectedSQL, int64(1), int64(1), int64(10), int64(1), int64(2), int64(1), int64(12))
}
func TestJoinQueryStruct(t *testing.T) {
expectedSql := `
expectedSQL := `
SELECT film_actor.actor_id AS "film_actor.actor_id",
film_actor.film_id AS "film_actor.film_id",
film_actor.last_update AS "film_actor.last_update",
@ -224,7 +224,7 @@ LIMIT 1000;
ORDER_BY(Film.FilmID.ASC()).
LIMIT(1000)
assertStatementSql(t, query, expectedSql, int64(1000))
assertStatementSql(t, query, expectedSQL, int64(1000))
var languageActorFilm []struct {
model.Language
@ -253,7 +253,7 @@ LIMIT 1000;
}
func TestJoinQuerySlice(t *testing.T) {
expectedSql := `
expectedSQL := `
SELECT language.language_id AS "language.language_id",
language.name AS "language.name",
language.last_update AS "language.last_update",
@ -290,7 +290,7 @@ LIMIT 15;
WHERE(Film.Rating.EQ(enum.MpaaRating.Nc17)).
LIMIT(15)
assertStatementSql(t, query, expectedSql, int64(15))
assertStatementSql(t, query, expectedSQL, int64(15))
err := query.Query(db, &filmsPerLanguage)
@ -657,7 +657,7 @@ func TestSelectOrderByAscDesc(t *testing.T) {
}
func TestSelectFullJoin(t *testing.T) {
expectedSql := `
expectedSQL := `
SELECT customer.customer_id AS "customer.customer_id",
customer.store_id AS "customer.store_id",
customer.first_name AS "customer.first_name",
@ -685,7 +685,7 @@ ORDER BY customer.customer_id ASC;
SELECT(Customer.AllColumns, Address.AllColumns).
ORDER_BY(Customer.CustomerID.ASC())
assertStatementSql(t, query, expectedSql)
assertStatementSql(t, query, expectedSQL)
allCustomersAndAddress := []struct {
Address *model.Address
@ -708,7 +708,7 @@ ORDER BY customer.customer_id ASC;
}
func TestSelectFullCrossJoin(t *testing.T) {
expectedSql := `
expectedSQL := `
SELECT customer.customer_id AS "customer.customer_id",
customer.store_id AS "customer.store_id",
customer.first_name AS "customer.first_name",
@ -738,7 +738,7 @@ LIMIT 1000;
ORDER_BY(Customer.CustomerID.ASC()).
LIMIT(1000)
assertStatementSql(t, query, expectedSql, int64(1000))
assertStatementSql(t, query, expectedSQL, int64(1000))
var customerAddresCrosJoined []struct {
model.Customer
@ -753,7 +753,7 @@ LIMIT 1000;
}
func TestSelectSelfJoin(t *testing.T) {
expectedSql := `
expectedSQL := `
SELECT f1.film_id AS "f1.film_id",
f1.title AS "f1.title",
f1.description AS "f1.description",
@ -793,7 +793,7 @@ ORDER BY f1.film_id ASC;
SELECT(f1.AllColumns, f2.AllColumns).
ORDER_BY(f1.FilmID.ASC())
assertStatementSql(t, query, expectedSql)
assertStatementSql(t, query, expectedSQL)
type F1 model.Film
type F2 model.Film
@ -813,7 +813,7 @@ ORDER BY f1.film_id ASC;
}
func TestSelectAliasColumn(t *testing.T) {
expectedSql := `
expectedSQL := `
SELECT f1.title AS "thesame_length_films.title1",
f2.title AS "thesame_length_films.title2",
f1.length AS "thesame_length_films.length"
@ -835,7 +835,7 @@ LIMIT 1000;
ORDER_BY(f1.Length.ASC(), f1.Title.ASC(), f2.Title.ASC()).
LIMIT(1000)
assertStatementSql(t, query, expectedSql, int64(1000))
assertStatementSql(t, query, expectedSQL, int64(1000))
type thesameLengthFilms struct {
Title1 string
@ -928,7 +928,7 @@ FROM dvds.film;
}
func TestSelectQueryScalar(t *testing.T) {
expectedSql := `
expectedSQL := `
SELECT film.film_id AS "film.film_id",
film.title AS "film.title",
film.description AS "film.description",
@ -960,7 +960,7 @@ ORDER BY film.film_id ASC;
WHERE(Film.RentalRate.EQ(maxFilmRentalRate)).
ORDER_BY(Film.FilmID.ASC())
assertStatementSql(t, query, expectedSql)
assertStatementSql(t, query, expectedSQL)
maxRentalRateFilms := []model.Film{}
err := query.Query(db, &maxRentalRateFilms)
@ -989,7 +989,7 @@ ORDER BY film.film_id ASC;
}
func TestSelectGroupByHaving(t *testing.T) {
expectedSql := `
expectedSQL := `
SELECT payment.customer_id AS "customer_payment_sum.customer_id",
SUM(payment.amount) AS "customer_payment_sum.amount_sum",
AVG(payment.amount) AS "customer_payment_sum.amount_avg",
@ -1018,7 +1018,7 @@ ORDER BY SUM(payment.amount) ASC;
SUMf(Payment.Amount).GT(Float(100)),
)
assertStatementSql(t, customersPaymentQuery, expectedSql, float64(100))
assertStatementSql(t, customersPaymentQuery, expectedSQL, float64(100))
type CustomerPaymentSum struct {
CustomerID int16
@ -1047,7 +1047,7 @@ ORDER BY SUM(payment.amount) ASC;
}
func TestSelectGroupBy2(t *testing.T) {
expectedSql := `
expectedSQL := `
SELECT customer.customer_id AS "customer.customer_id",
customer.store_id AS "customer.store_id",
customer.first_name AS "customer.first_name",
@ -1088,7 +1088,7 @@ ORDER BY customer_payment_sum."amount_sum" ASC;
).
ORDER_BY(amountSum.ASC())
assertStatementSql(t, query, expectedSql)
assertStatementSql(t, query, expectedSQL)
type CustomerWithAmounts struct {
Customer *model.Customer
@ -1157,7 +1157,7 @@ func TestSelectStaff(t *testing.T) {
func TestSelectTimeColumns(t *testing.T) {
expectedSql := `
expectedSQL := `
SELECT payment.payment_id AS "payment.payment_id",
payment.customer_id AS "payment.customer_id",
payment.staff_id AS "payment.staff_id",
@ -1173,7 +1173,7 @@ ORDER BY payment.payment_date ASC;
WHERE(Payment.PaymentDate.LT(Timestamp(2007, 02, 14, 22, 16, 01, 0))).
ORDER_BY(Payment.PaymentDate.ASC())
assertStatementSql(t, query, expectedSql, "2007-02-14 22:16:01.000")
assertStatementSql(t, query, expectedSQL, "2007-02-14 22:16:01.000")
payments := []model.Payment{}
@ -1260,8 +1260,8 @@ func TestAllSetOperators(t *testing.T) {
UNION_ALL,
INTERSECT,
INTERSECT_ALL,
EXCEPT,
EXCEPT_ALL,
//EXCEPT,
//EXCEPT_ALL,
}
expectedDestLen := []int{
@ -1316,7 +1316,7 @@ LIMIT 20;
}
func TestLockTable(t *testing.T) {
expectedSql := `
expectedSQL := `
LOCK TABLE dvds.address IN`
var testData = []TableLockMode{
@ -1333,7 +1333,7 @@ LOCK TABLE dvds.address IN`
for _, lockMode := range testData {
query := Address.LOCK().IN(lockMode)
assertStatementSql(t, query, expectedSql+" "+string(lockMode)+" MODE;\n")
assertStatementSql(t, query, expectedSQL+" "+string(lockMode)+" MODE;\n")
tx, _ := db.Begin()
@ -1349,7 +1349,7 @@ LOCK TABLE dvds.address IN`
for _, lockMode := range testData {
query := Address.LOCK().IN(lockMode).NOWAIT()
assertStatementSql(t, query, expectedSql+" "+string(lockMode)+" MODE NOWAIT;\n")
assertStatementSql(t, query, expectedSQL+" "+string(lockMode)+" MODE NOWAIT;\n")
tx, _ := db.Begin()
@ -1373,7 +1373,7 @@ func getRowLockTestData() map[SelectLock]string {
}
func TestRowLock(t *testing.T) {
expectedSql := `
expectedSQL := `
SELECT *
FROM dvds.address
LIMIT 3
@ -1385,7 +1385,7 @@ FOR`
for lockType, lockTypeStr := range getRowLockTestData() {
query.FOR(lockType)
assertStatementSql(t, query, expectedSql+" "+lockTypeStr+";\n", int64(3))
assertStatementSql(t, query, expectedSQL+" "+lockTypeStr+";\n", int64(3))
tx, _ := db.Begin()
@ -1401,7 +1401,7 @@ FOR`
for lockType, lockTypeStr := range getRowLockTestData() {
query.FOR(lockType.NOWAIT())
assertStatementSql(t, query, expectedSql+" "+lockTypeStr+" NOWAIT;\n", int64(3))
assertStatementSql(t, query, expectedSQL+" "+lockTypeStr+" NOWAIT;\n", int64(3))
tx, _ := db.Begin()
@ -1417,7 +1417,7 @@ FOR`
for lockType, lockTypeStr := range getRowLockTestData() {
query.FOR(lockType.SKIP_LOCKED())
assertStatementSql(t, query, expectedSql+" "+lockTypeStr+" SKIP LOCKED;\n", int64(3))
assertStatementSql(t, query, expectedSQL+" "+lockTypeStr+" SKIP LOCKED;\n", int64(3))
tx, _ := db.Begin()
@ -1433,7 +1433,7 @@ FOR`
func TestQuickStart(t *testing.T) {
var expectedSql = `
var expectedSQL = `
SELECT actor.actor_id AS "actor.actor_id",
actor.first_name AS "actor.first_name",
actor.last_name AS "actor.last_name",
@ -1488,7 +1488,7 @@ ORDER BY actor.actor_id ASC, film.film_id ASC;
Film.FilmID.ASC(),
)
assertStatementSql(t, stmt, expectedSql, "English", "Action", int64(180))
assertStatementSql(t, stmt, expectedSQL, "English", "Action", int64(180))
var dest []struct {
model.Actor

View file

@ -16,12 +16,12 @@ func TestUpdateValues(t *testing.T) {
SET("Bong", "http://bong.com").
WHERE(Link.Name.EQ(String("Bing")))
var expectedSql = `
var expectedSQL = `
UPDATE test_sample.link
SET (name, url) = ('Bong', 'http://bong.com')
WHERE link.name = 'Bing';
`
assertStatementSql(t, query, expectedSql, "Bong", "http://bong.com", "Bing")
assertStatementSql(t, query, expectedSQL, "Bong", "http://bong.com", "Bing")
assertExec(t, query, 1)
@ -54,7 +54,7 @@ func TestUpdateWithSubQueries(t *testing.T) {
).
WHERE(Link.Name.EQ(String("Bing")))
expectedSql := `
expectedSQL := `
UPDATE test_sample.link
SET (name, url) = ((
SELECT 'Bong'
@ -66,7 +66,7 @@ SET (name, url) = ((
WHERE link.name = 'Bing';
`
assertStatementSql(t, query, expectedSql, "Bong", "Bing", "Bing")
assertStatementSql(t, query, expectedSQL, "Bong", "Bing", "Bing")
assertExec(t, query, 1)
}
@ -74,7 +74,7 @@ WHERE link.name = 'Bing';
func TestUpdateAndReturning(t *testing.T) {
setupLinkTableForUpdateTest(t)
expectedSql := `
expectedSQL := `
UPDATE test_sample.link
SET (name, url) = ('DuckDuckGo', 'http://www.duckduckgo.com')
WHERE link.name = 'Ask'
@ -90,7 +90,7 @@ RETURNING link.id AS "link.id",
WHERE(Link.Name.EQ(String("Ask"))).
RETURNING(Link.AllColumns)
assertStatementSql(t, stmt, expectedSql, "DuckDuckGo", "http://www.duckduckgo.com", "Ask")
assertStatementSql(t, stmt, expectedSQL, "DuckDuckGo", "http://www.duckduckgo.com", "Ask")
links := []model.Link{}
@ -112,7 +112,7 @@ func TestUpdateWithSelect(t *testing.T) {
).
WHERE(Link.ID.EQ(Int(0)))
expectedSql := `
expectedSQL := `
UPDATE test_sample.link
SET (id, url, name, description) = (
SELECT link.id AS "link.id",
@ -124,7 +124,7 @@ SET (id, url, name, description) = (
)
WHERE link.id = 0;
`
assertStatementSql(t, stmt, expectedSql, int64(0), int64(0))
assertStatementSql(t, stmt, expectedSQL, int64(0), int64(0))
assertExec(t, stmt, 1)
}
@ -139,7 +139,7 @@ func TestUpdateWithInvalidSelect(t *testing.T) {
).
WHERE(Link.ID.EQ(Int(0)))
var expectedSql = `
var expectedSQL = `
UPDATE test_sample.link
SET (id, url, name, description) = (
SELECT link.id AS "link.id",
@ -149,7 +149,7 @@ SET (id, url, name, description) = (
)
WHERE link.id = 0;
`
assertStatementSql(t, stmt, expectedSql, int64(0), int64(0))
assertStatementSql(t, stmt, expectedSQL, int64(0), int64(0))
assertExecErr(t, stmt, "pq: number of columns does not match number of values")
}
@ -168,12 +168,12 @@ func TestUpdateWithModelData(t *testing.T) {
MODEL(link).
WHERE(Link.ID.EQ(Int(int64(link.ID))))
expectedSql := `
expectedSQL := `
UPDATE test_sample.link
SET (id, url, name, description) = (201, 'http://www.duckduckgo.com', 'DuckDuckGo', NULL)
WHERE link.id = 201;
`
assertStatementSql(t, stmt, expectedSql, int32(201), "http://www.duckduckgo.com", "DuckDuckGo", nil, int64(201))
assertStatementSql(t, stmt, expectedSQL, int32(201), "http://www.duckduckgo.com", "DuckDuckGo", nil, int64(201))
assertExec(t, stmt, 1)
}
@ -195,12 +195,12 @@ func TestUpdateWithModelDataAndPredefinedColumnList(t *testing.T) {
MODEL(link).
WHERE(Link.ID.EQ(Int(int64(link.ID))))
var expectedSql = `
var expectedSQL = `
UPDATE test_sample.link
SET (description, name, url) = (NULL, 'DuckDuckGo', 'http://www.duckduckgo.com')
WHERE link.id = 201;
`
assertStatementSql(t, stmt, expectedSql, nil, "DuckDuckGo", "http://www.duckduckgo.com", int64(201))
assertStatementSql(t, stmt, expectedSQL, nil, "DuckDuckGo", "http://www.duckduckgo.com", int64(201))
assertExec(t, stmt, 1)
}
@ -231,12 +231,12 @@ func TestUpdateWithInvalidModelData(t *testing.T) {
MODEL(link).
WHERE(Link.ID.EQ(Int(int64(link.Ident))))
var expectedSql = `
var expectedSQL = `
UPDATE test_sample.link
SET (id, url, name, description, rel) = ('http://www.duckduckgo.com', 'DuckDuckGo', NULL, NULL)
WHERE link.id = 201;
`
assertStatementSql(t, stmt, expectedSql, "http://www.duckduckgo.com", "DuckDuckGo", nil, nil, int64(201))
assertStatementSql(t, stmt, expectedSQL, "http://www.duckduckgo.com", "DuckDuckGo", nil, nil, int64(201))
assertExecErr(t, stmt, "pq: number of columns does not match number of values")
}