mirror of
https://gitea.invidious.io/iv-org/shard-crystal-sqlite3.git
synced 2024-08-15 00:53:26 +00:00
Add spec for DB.connect
Update to crystal-db ~> 0.4.0
This commit is contained in:
parent
bbed6256a6
commit
b43a12fc92
4 changed files with 21 additions and 3 deletions
|
@ -4,7 +4,7 @@ version: 0.8.1
|
|||
dependencies:
|
||||
db:
|
||||
github: crystal-lang/crystal-db
|
||||
version: ~> 0.3.1
|
||||
version: ~> 0.4.0
|
||||
|
||||
authors:
|
||||
- Ary Borenszweig <aborenszweig@manas.com.ar>
|
||||
|
|
|
@ -57,4 +57,15 @@ describe Connection do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
it "opens a connection without the pool" do
|
||||
with_cnn do |cnn|
|
||||
cnn.should be_a(SQLite3::Connection)
|
||||
|
||||
cnn.exec "create table person (name string, age integer)"
|
||||
cnn.exec "insert into person values (\"foo\", 10)"
|
||||
|
||||
cnn.scalar("select count(*) from person").should eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,6 +12,13 @@ ensure
|
|||
File.delete(DB_FILENAME)
|
||||
end
|
||||
|
||||
def with_cnn(&block : DB::Connection ->)
|
||||
File.delete(DB_FILENAME) rescue nil
|
||||
DB.connect "sqlite3:#{DB_FILENAME}", &block
|
||||
ensure
|
||||
File.delete(DB_FILENAME)
|
||||
end
|
||||
|
||||
def with_db(name, &block : DB::Database ->)
|
||||
File.delete(name) rescue nil
|
||||
DB.open "sqlite3:#{name}", &block
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class SQLite3::Driver < DB::Driver
|
||||
def build_connection(db)
|
||||
SQLite3::Connection.new(db)
|
||||
def build_connection(context : DB::ConnectionContext)
|
||||
SQLite3::Connection.new(context)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue