Use text instead of string as sqlite type

Ref: crystal-lang/crystal-db#71
This commit is contained in:
Brian J. Cardiff 2017-11-13 10:59:59 -03:00
parent adf64daa08
commit ae84010c28
4 changed files with 7 additions and 7 deletions

View File

@ -20,7 +20,7 @@ dependencies:
require "sqlite3"
DB.open "sqlite3://./data.db" do |db|
db.exec "create table contacts (name string, age integer)"
db.exec "create table contacts (name text, age integer)"
db.exec "insert into contacts values (?, ?)", "John Doe", 30
args = [] of DB::Any

View File

@ -2,7 +2,7 @@ require "db"
require "../src/sqlite3"
DB.open "sqlite3://%3Amemory%3A" do |db|
db.exec "create table contacts (name string, age integer)"
db.exec "create table contacts (name text, age integer)"
db.exec "insert into contacts values (?, ?)", "John Doe", 30
args = [] of DB::Any

View File

@ -14,7 +14,7 @@ describe Connection do
it "opens a database and then backs it up to another db" do
with_db do |db|
with_db("./test2.db") do |backup_db|
db.exec "create table person (name string, age integer)"
db.exec "create table person (name text, age integer)"
db.exec "insert into person values (\"foo\", 10)"
dump db, backup_db
@ -32,7 +32,7 @@ describe Connection do
it "opens a database, inserts records, dumps to an in-memory db, insers some more, then dumps to the source" do
with_db do |db|
with_mem_db do |in_memory_db|
db.exec "create table person (name string, age integer)"
db.exec "create table person (name text, age integer)"
db.exec "insert into person values (\"foo\", 10)"
dump db, in_memory_db
@ -48,7 +48,7 @@ describe Connection do
it "opens a database, inserts records (>1024K), and dumps to an in-memory db" do
with_db do |db|
with_mem_db do |in_memory_db|
db.exec "create table person (name string, age integer)"
db.exec "create table person (name text, age integer)"
db.transaction do |tx|
100_000.times { tx.connection.exec "insert into person values (\"foo\", 10)" }
end
@ -62,7 +62,7 @@ describe Connection do
with_cnn do |cnn|
cnn.should be_a(SQLite3::Connection)
cnn.exec "create table person (name string, age integer)"
cnn.exec "create table person (name text, age integer)"
cnn.exec "insert into person values (\"foo\", 10)"
cnn.scalar("select count(*) from person").should eq(1)

View File

@ -80,7 +80,7 @@ DB::DriverSpecs(DB::Any).run do
end
it "gets last insert row id", prepared: :both do |db|
db.exec "create table person (name string, age integer)"
db.exec "create table person (name text, age integer)"
db.exec %(insert into person values ("foo", 10))
res = db.exec %(insert into person values ("foo", 10))
res.last_insert_id.should eq(2)