-
-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
238 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package TestIssues | ||
|
||
import "testing" | ||
|
||
func TestIssue486(t *testing.T) { | ||
db, err := getDB() | ||
if err != nil { | ||
t.Error(err) | ||
return | ||
} | ||
defer func() { | ||
err = db.Close() | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
}() | ||
var value string | ||
err = db.QueryRow("SELECT 'AAA안녕하세요' FROM dual").Scan(&value) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
if value != "AAA안녕하세요" { | ||
t.Errorf("expected %s and got %s", "AAA안녕하세요", value) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package TestIssues | ||
|
||
import ( | ||
"database/sql" | ||
"strconv" | ||
"testing" | ||
) | ||
|
||
func TestIssue532(t *testing.T) { | ||
type TTB_DATA struct { | ||
ID int `db:"ID"` | ||
Name string `db:"NAME"` | ||
} | ||
var createTable = func(db *sql.DB) error { | ||
return execCmd(db, `CREATE TABLE TTB_532( | ||
EMP_ID NUMBER, | ||
EMP_NAME VARCHAR2(255), | ||
PRIMARY KEY (EMP_ID) | ||
)`) | ||
} | ||
|
||
var dropTable = func(db *sql.DB) error { | ||
return execCmd(db, "drop table TTB_532 purge") | ||
} | ||
|
||
var insert = func(db *sql.DB, rowNum int) error { | ||
data := make([]TTB_DATA, rowNum) | ||
for index := range data { | ||
data[index].ID = index + 1 | ||
data[index].Name = "NAME_" + strconv.Itoa(index+1) | ||
} | ||
_, err := db.Exec(`INSERT INTO TTB_532(EMP_ID, EMP_NAME) VALUES(:ID, :NAME)`, data) | ||
return err | ||
} | ||
|
||
var query = func(db *sql.DB) error { | ||
rows, err := db.Query("SELECT * FROM TTB_532 FOR UPDATE") | ||
if err != nil { | ||
return err | ||
} | ||
defer func() { | ||
err = rows.Close() | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
}() | ||
return nil | ||
} | ||
db, err := getDB() | ||
if err != nil { | ||
t.Error(err) | ||
return | ||
} | ||
defer func() { | ||
err = db.Close() | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
}() | ||
err = createTable(db) | ||
if err != nil { | ||
t.Error(err) | ||
return | ||
} | ||
defer func() { | ||
err = dropTable(db) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
}() | ||
err = insert(db, 7) | ||
if err != nil { | ||
t.Error(err) | ||
return | ||
} | ||
err = query(db) | ||
if err != nil { | ||
t.Error(err) | ||
return | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package TestIssues | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestIssue543(t *testing.T) { | ||
expected := "CASE WHEN \"SESSION_ID\" IS NULL THEN \"SECURITY_GROUP_ID\" END " | ||
db, err := getDB() | ||
if err != nil { | ||
t.Error(err) | ||
return | ||
} | ||
defer func() { | ||
err = db.Close() | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
}() | ||
var result string | ||
err = db.QueryRow("select column_expression from dba_ind_expressions where index_owner = 'APEX_230200' and index_name = 'WWV_FLOW_WORKSHEET_RPTS_UK' and column_position = 1").Scan(&result) | ||
if err != nil { | ||
t.Error(err) | ||
return | ||
} | ||
if result != expected { | ||
t.Errorf("expected: %s and got: %s", expected, result) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package TestIssues | ||
|
||
import ( | ||
"database/sql" | ||
go_ora "github.com/sijms/go-ora/v2" | ||
"testing" | ||
) | ||
|
||
func TestLargeUDTArray(t *testing.T) { | ||
var createTypes = func(db *sql.DB) error { | ||
return execCmd(db, ` | ||
create or replace type stringsType as object( | ||
STRING1 varchar2(60), | ||
STRING2 varchar2(300) | ||
)`, `create or replace type stringsTypeCol as table of stringsType`) | ||
} | ||
var dropTypes = func(db *sql.DB) error { | ||
return execCmd(db, "DROP TYPE stringsTypeCol", "DROP TYPE stringsType") | ||
} | ||
type StringsType struct { | ||
String1 string `udt:"STRING1"` | ||
String2 string `udt:"STRING2"` | ||
} | ||
var inputPars = func(db *sql.DB, input []StringsType) (int, error) { | ||
var length int | ||
_, err := db.Exec(` | ||
DECLARE | ||
inp stringsTypeCol; | ||
BEGIN | ||
inp := :1; | ||
:2 := inp.count; | ||
END;`, input, go_ora.Out{Dest: &length}) | ||
return length, err | ||
} | ||
var outputPars = func(db *sql.DB, length int) ([]StringsType, error) { | ||
var output []StringsType | ||
_, err := db.Exec(` | ||
declare | ||
outp stringsTypeCol; | ||
ext number; | ||
begin | ||
ext := :1; | ||
outp := stringsTypeCol(); | ||
outp.extend(ext); | ||
for n in 1..ext | ||
loop | ||
outp(n) := stringsType('string1','string2'); | ||
end loop; | ||
:2 := outp; | ||
end; | ||
`, length, go_ora.Out{Dest: &output}) | ||
return output, err | ||
} | ||
db, err := getDB() | ||
if err != nil { | ||
t.Error(err) | ||
return | ||
} | ||
defer func() { | ||
err = db.Close() | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
}() | ||
err = createTypes(db) | ||
if err != nil { | ||
t.Error(err) | ||
return | ||
} | ||
defer func() { | ||
err = dropTypes(db) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
}() | ||
err = go_ora.RegisterType(db, "stringsType", "stringsTypeCol", StringsType{}) | ||
if err != nil { | ||
t.Error(err) | ||
return | ||
} | ||
size := 0x200 | ||
output, err := inputPars(db, make([]StringsType, size)) | ||
if err != nil { | ||
t.Error(err) | ||
return | ||
} | ||
if output != size { | ||
t.Errorf("expected size: %d and got: %d", size, output) | ||
return | ||
} | ||
outputArray, err := outputPars(db, size) | ||
if err != nil { | ||
t.Error(err) | ||
return | ||
} | ||
if len(outputArray) != size { | ||
t.Errorf("expected size: %d and got: %d", size, len(outputArray)) | ||
} | ||
|
||
} |