2008-02-01 18:43:44 -05:00
|
|
|
USING: io io.files io.launcher kernel namespaces
|
2008-02-04 14:32:27 -05:00
|
|
|
prettyprint tools.test db.sqlite db sequences
|
2008-02-12 18:10:56 -05:00
|
|
|
continuations db.types ;
|
2008-02-01 18:43:44 -05:00
|
|
|
IN: temporary
|
|
|
|
|
|
|
|
: test.db "extra/db/sqlite/test.db" resource-path ;
|
|
|
|
|
2008-02-06 14:47:19 -05:00
|
|
|
[ ] [ [ test.db delete-file ] ignore-errors ] unit-test
|
2008-02-01 18:43:44 -05:00
|
|
|
|
2008-02-04 14:57:22 -05:00
|
|
|
[ ] [
|
|
|
|
test.db [
|
|
|
|
"create table person (name varchar(30), country varchar(30))" sql-command
|
|
|
|
"insert into person values('John', 'America')" sql-command
|
|
|
|
"insert into person values('Jane', 'New Zealand')" sql-command
|
|
|
|
] with-sqlite
|
|
|
|
] unit-test
|
2008-02-01 18:43:44 -05:00
|
|
|
|
|
|
|
|
2008-02-04 14:57:22 -05:00
|
|
|
[ { { "John" "America" } { "Jane" "New Zealand" } } ] [
|
2008-02-03 16:06:31 -05:00
|
|
|
test.db [
|
2008-02-03 00:28:33 -05:00
|
|
|
"select * from person" sql-query
|
|
|
|
] with-sqlite
|
|
|
|
] unit-test
|
2008-02-01 18:43:44 -05:00
|
|
|
|
2008-02-04 14:57:22 -05:00
|
|
|
[ { { "John" "America" } } ] [
|
2008-02-03 16:06:31 -05:00
|
|
|
test.db [
|
2008-02-01 18:43:44 -05:00
|
|
|
"select * from person where name = :name and country = :country"
|
2008-02-03 00:28:33 -05:00
|
|
|
<simple-statement> [
|
2008-02-12 18:10:56 -05:00
|
|
|
{ { ":name" "Jane" TEXT } { ":country" "New Zealand" TEXT } }
|
2008-02-03 00:28:33 -05:00
|
|
|
over do-bound-query
|
2008-02-01 18:43:44 -05:00
|
|
|
|
2008-02-03 00:28:33 -05:00
|
|
|
{ { "Jane" "New Zealand" } } =
|
|
|
|
[ "test fails" throw ] unless
|
2008-02-01 18:43:44 -05:00
|
|
|
|
2008-02-12 18:10:56 -05:00
|
|
|
{ { ":name" "John" TEXT } { ":country" "America" TEXT } }
|
2008-02-03 00:28:33 -05:00
|
|
|
swap do-bound-query
|
|
|
|
] with-disposal
|
2008-02-01 18:43:44 -05:00
|
|
|
] with-sqlite
|
|
|
|
] unit-test
|
|
|
|
|
2008-02-04 14:57:22 -05:00
|
|
|
[ { { "1" "John" "America" } { "2" "Jane" "New Zealand" } } ]
|
|
|
|
[ test.db [ "select rowid, * from person" sql-query ] with-sqlite ] unit-test
|
2008-02-01 18:43:44 -05:00
|
|
|
|
2008-02-04 14:57:22 -05:00
|
|
|
[ ] [
|
2008-02-03 16:06:31 -05:00
|
|
|
test.db [
|
2008-02-01 18:43:44 -05:00
|
|
|
"insert into person(name, country) values('Jimmy', 'Canada')"
|
2008-02-03 00:28:33 -05:00
|
|
|
sql-command
|
2008-02-01 18:43:44 -05:00
|
|
|
] with-sqlite
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[
|
|
|
|
{
|
|
|
|
{ "1" "John" "America" }
|
|
|
|
{ "2" "Jane" "New Zealand" }
|
|
|
|
{ "3" "Jimmy" "Canada" }
|
|
|
|
}
|
2008-02-03 00:28:33 -05:00
|
|
|
] [ test.db [ "select rowid, * from person" sql-query ] with-sqlite ] unit-test
|
2008-02-01 18:43:44 -05:00
|
|
|
|
|
|
|
[
|
2008-02-03 16:06:31 -05:00
|
|
|
test.db [
|
2008-02-01 18:43:44 -05:00
|
|
|
[
|
2008-02-03 00:28:33 -05:00
|
|
|
"insert into person(name, country) values('Jose', 'Mexico')" sql-command
|
|
|
|
"insert into person(name, country) values('Jose', 'Mexico')" sql-command
|
2008-02-01 18:43:44 -05:00
|
|
|
"oops" throw
|
|
|
|
] with-transaction
|
|
|
|
] with-sqlite
|
2008-02-06 14:47:19 -05:00
|
|
|
] must-fail
|
2008-02-01 18:43:44 -05:00
|
|
|
|
|
|
|
[ 3 ] [
|
2008-02-03 16:06:31 -05:00
|
|
|
test.db [
|
2008-02-03 00:28:33 -05:00
|
|
|
"select * from person" sql-query length
|
2008-02-01 18:43:44 -05:00
|
|
|
] with-sqlite
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[
|
|
|
|
] [
|
2008-02-03 16:06:31 -05:00
|
|
|
test.db [
|
2008-02-01 18:43:44 -05:00
|
|
|
[
|
2008-02-03 00:28:33 -05:00
|
|
|
"insert into person(name, country) values('Jose', 'Mexico')"
|
|
|
|
sql-command
|
|
|
|
"insert into person(name, country) values('Jose', 'Mexico')"
|
|
|
|
sql-command
|
2008-02-01 18:43:44 -05:00
|
|
|
] with-transaction
|
|
|
|
] with-sqlite
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[ 5 ] [
|
2008-02-03 16:06:31 -05:00
|
|
|
test.db [
|
2008-02-03 00:28:33 -05:00
|
|
|
"select * from person" sql-query length
|
2008-02-01 18:43:44 -05:00
|
|
|
] with-sqlite
|
|
|
|
] unit-test
|