diff --git a/func_expression.go b/func_expression.go index 84c55b0..91fa61a 100644 --- a/func_expression.go +++ b/func_expression.go @@ -168,7 +168,7 @@ func UPPER(stringExpression StringExpression) StringExpression { // in characters (a space by default) from the start and end of string func BTRIM(stringExpression StringExpression, trimChars ...StringExpression) StringExpression { if len(trimChars) > 0 { - return newStringFunc("LTRIM", stringExpression, trimChars[0]) + return newStringFunc("BTRIM", stringExpression, trimChars[0]) } return newStringFunc("BTRIM", stringExpression) } diff --git a/func_expression_test.go b/func_expression_test.go index 9b7f5b1..fa4a0a5 100644 --- a/func_expression_test.go +++ b/func_expression_test.go @@ -155,3 +155,8 @@ func TestFuncLEAST(t *testing.T) { assertClauseSerialize(t, LEAST(table1ColFloat), "LEAST(table1.col_float)") assertClauseSerialize(t, LEAST(Float(11.2222), NULL, String("str")), "LEAST($1, NULL, $2)", float64(11.2222), "str") } + +func TestTO_ASCII(t *testing.T) { + assertClauseSerialize(t, TO_ASCII(String("Karel")), `TO_ASCII($1)`, "Karel") + assertClauseSerialize(t, TO_ASCII(String("Karel")), `TO_ASCII($1)`, "Karel") +} diff --git a/tests/all_types_test.go b/tests/all_types_test.go index 23111fc..b6d9dad 100644 --- a/tests/all_types_test.go +++ b/tests/all_types_test.go @@ -127,7 +127,10 @@ func TestStringOperators(t *testing.T) { LOWER(AllTypes.CharacterVaryingPtr), UPPER(AllTypes.Character), BTRIM(AllTypes.CharacterVarying), + BTRIM(AllTypes.CharacterVarying, String("AA")), + LTRIM(AllTypes.CharacterVarying), LTRIM(AllTypes.CharacterVarying, String("A")), + RTRIM(AllTypes.CharacterVarying), RTRIM(AllTypes.CharacterVarying, String("B")), CHR(Int(65)), //CONCAT(String("string1"), Int(1), Float(11.12)), @@ -143,13 +146,16 @@ func TestStringOperators(t *testing.T) { RIGHT(String("abcde"), Int(2)), LENGTH(String("jose")), LENGTH(String("jose"), String("UTF8")), + LPAD(String("Hi"), Int(5)), LPAD(String("Hi"), Int(5), String("xy")), + RPAD(String("Hi"), Int(5)), RPAD(String("Hi"), Int(5), String("xy")), MD5(AllTypes.CharacterVarying), REPEAT(AllTypes.Text, Int(33)), REPLACE(AllTypes.Character, String("BA"), String("AB")), REVERSE(AllTypes.CharacterVarying), STRPOS(AllTypes.Text, String("A")), + SUBSTR(AllTypes.CharacterPtr, Int(3)), SUBSTR(AllTypes.CharacterPtr, Int(3), Int(2)), TO_HEX(AllTypes.IntegerPtr), ) diff --git a/tests/delete_test.go b/tests/delete_test.go index ed79b87..732a3dd 100644 --- a/tests/delete_test.go +++ b/tests/delete_test.go @@ -73,7 +73,7 @@ func TestDeleteQueryContext(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), 1*time.Microsecond) defer cancel() - time.Sleep(10 * time.Microsecond) + time.Sleep(10 * time.Millisecond) dest := []model.Link{} err := deleteStmt.QueryContext(ctx, db, &dest) @@ -91,7 +91,7 @@ func TestDeleteExecContext(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), 1*time.Microsecond) defer cancel() - time.Sleep(10 * time.Microsecond) + time.Sleep(10 * time.Millisecond) _, err := deleteStmt.ExecContext(ctx, db) diff --git a/tests/insert_test.go b/tests/insert_test.go index 17ffca0..81f3a13 100644 --- a/tests/insert_test.go +++ b/tests/insert_test.go @@ -258,7 +258,7 @@ func TestInsertWithQueryContext(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), 1*time.Microsecond) defer cancel() - time.Sleep(10 * time.Microsecond) + time.Sleep(10 * time.Millisecond) dest := []model.Link{} err := stmt.QueryContext(ctx, db, &dest) @@ -275,7 +275,7 @@ func TestInsertWithExecContext(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), 1*time.Microsecond) defer cancel() - time.Sleep(10 * time.Microsecond) + time.Sleep(10 * time.Millisecond) _, err := stmt.ExecContext(ctx, db) diff --git a/tests/lock_test.go b/tests/lock_test.go index 8661efc..fdc4dc4 100644 --- a/tests/lock_test.go +++ b/tests/lock_test.go @@ -62,7 +62,7 @@ func TestLockExecContext(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), 1*time.Microsecond) defer cancel() - time.Sleep(10 * time.Microsecond) + time.Sleep(10 * time.Millisecond) tx, _ := db.Begin() defer tx.Rollback() diff --git a/tests/update_test.go b/tests/update_test.go index 768231b..ff48f16 100644 --- a/tests/update_test.go +++ b/tests/update_test.go @@ -254,7 +254,7 @@ func TestUpdateQueryContext(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), 1*time.Microsecond) defer cancel() - time.Sleep(10 * time.Microsecond) + time.Sleep(10 * time.Millisecond) dest := []model.Link{} err := updateStmt.QueryContext(ctx, db, &dest) @@ -273,7 +273,7 @@ func TestUpdateExecContext(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), 1*time.Microsecond) defer cancel() - time.Sleep(10 * time.Microsecond) + time.Sleep(10 * time.Millisecond) _, err := updateStmt.ExecContext(ctx, db)