mirror of
https://gitea.invidious.io/iv-org/shard-crystal-sqlite3.git
synced 2024-08-15 00:53:26 +00:00
Add sample_value specs
Unify style for sql queries
This commit is contained in:
parent
51364e2512
commit
be5ceaa0bf
2 changed files with 12 additions and 10 deletions
|
@ -34,7 +34,9 @@ DB::DriverSpecs(DB::Any).run do
|
||||||
sample_value 1.5_f32, "float", "1.5", type_safe_value: false
|
sample_value 1.5_f32, "float", "1.5", type_safe_value: false
|
||||||
sample_value 1.5, "float", "1.5"
|
sample_value 1.5, "float", "1.5"
|
||||||
sample_value Time.utc(2016, 2, 15), "text", "'2016-02-15 00:00:00.000'", type_safe_value: false
|
sample_value Time.utc(2016, 2, 15), "text", "'2016-02-15 00:00:00.000'", type_safe_value: false
|
||||||
|
sample_value Time.utc(2016, 2, 15, 10, 15, 30), "text", "'2016-02-15 10:15:30'", type_safe_value: false
|
||||||
sample_value Time.utc(2016, 2, 15, 10, 15, 30), "text", "'2016-02-15 10:15:30.000'", type_safe_value: false
|
sample_value Time.utc(2016, 2, 15, 10, 15, 30), "text", "'2016-02-15 10:15:30.000'", type_safe_value: false
|
||||||
|
sample_value Time.utc(2016, 2, 15, 10, 15, 30, nanosecond: 123000000), "text", "'2016-02-15 10:15:30.123'", type_safe_value: false
|
||||||
sample_value Time.local(2016, 2, 15, 7, 15, 30, location: Time::Location.fixed("fixed", -3*3600)), "text", "'2016-02-15 10:15:30.000'", type_safe_value: false
|
sample_value Time.local(2016, 2, 15, 7, 15, 30, location: Time::Location.fixed("fixed", -3*3600)), "text", "'2016-02-15 10:15:30.000'", type_safe_value: false
|
||||||
|
|
||||||
ary = UInt8[0x53, 0x51, 0x4C, 0x69, 0x74, 0x65]
|
ary = UInt8[0x53, 0x51, 0x4C, 0x69, 0x74, 0x65]
|
||||||
|
|
|
@ -3,8 +3,8 @@ require "./spec_helper"
|
||||||
describe SQLite3::ResultSet do
|
describe SQLite3::ResultSet do
|
||||||
it "reads integer data types" do
|
it "reads integer data types" do
|
||||||
with_db do |db|
|
with_db do |db|
|
||||||
db.exec "CREATE TABLE test_table(test_int integer)"
|
db.exec "CREATE TABLE test_table (test_int integer)"
|
||||||
db.exec "INSERT INTO test_table(test_int) values(?)", 42
|
db.exec "INSERT INTO test_table (test_int) values (?)", 42
|
||||||
db.query("SELECT test_int FROM test_table") do |rs|
|
db.query("SELECT test_int FROM test_table") do |rs|
|
||||||
rs.each do
|
rs.each do
|
||||||
rs.read.should eq(42)
|
rs.read.should eq(42)
|
||||||
|
@ -15,8 +15,8 @@ describe SQLite3::ResultSet do
|
||||||
|
|
||||||
it "reads string data types" do
|
it "reads string data types" do
|
||||||
with_db do |db|
|
with_db do |db|
|
||||||
db.exec "CREATE TABLE test_table(test_text text)"
|
db.exec "CREATE TABLE test_table (test_text text)"
|
||||||
db.exec "INSERT INTO test_table(test_text) VALUES (?), (?)", "abc", "123"
|
db.exec "INSERT INTO test_table (test_text) values (?), (?)", "abc", "123"
|
||||||
db.query("SELECT test_text FROM test_table") do |rs|
|
db.query("SELECT test_text FROM test_table") do |rs|
|
||||||
rs.each do
|
rs.each do
|
||||||
rs.read.should match(/abc|123/)
|
rs.read.should match(/abc|123/)
|
||||||
|
@ -27,9 +27,9 @@ describe SQLite3::ResultSet do
|
||||||
|
|
||||||
it "reads time data types" do
|
it "reads time data types" do
|
||||||
with_db do |db|
|
with_db do |db|
|
||||||
db.exec "CREATE TABLE test_table(test_date datetime)"
|
db.exec "CREATE TABLE test_table (test_date datetime)"
|
||||||
timestamp = Time.utc
|
timestamp = Time.utc
|
||||||
db.exec "INSERT INTO test_table(test_date) values(current_timestamp)"
|
db.exec "INSERT INTO test_table (test_date) values (current_timestamp)"
|
||||||
db.query("SELECT test_date FROM test_table") do |rs|
|
db.query("SELECT test_date FROM test_table") do |rs|
|
||||||
rs.each do
|
rs.each do
|
||||||
rs.read(Time).should be_close(timestamp, 1.second)
|
rs.read(Time).should be_close(timestamp, 1.second)
|
||||||
|
@ -40,13 +40,13 @@ describe SQLite3::ResultSet do
|
||||||
|
|
||||||
it "reads time stored in text fields, too" do
|
it "reads time stored in text fields, too" do
|
||||||
with_db do |db|
|
with_db do |db|
|
||||||
db.exec "CREATE TABLE test_table(test_date text)"
|
db.exec "CREATE TABLE test_table (test_date text)"
|
||||||
timestamp = Time.utc
|
timestamp = Time.utc
|
||||||
# Try 3 different ways: our own two formats and using SQLite's current_timestamp.
|
# Try 3 different ways: our own two formats and using SQLite's current_timestamp.
|
||||||
# They should all work.
|
# They should all work.
|
||||||
db.exec "INSERT INTO test_table(test_date) values(?)", timestamp.to_s SQLite3::DATE_FORMAT_SUBSECOND
|
db.exec "INSERT INTO test_table (test_date) values (?)", timestamp.to_s SQLite3::DATE_FORMAT_SUBSECOND
|
||||||
db.exec "INSERT INTO test_table(test_date) values(?)", timestamp.to_s SQLite3::DATE_FORMAT_SECOND
|
db.exec "INSERT INTO test_table (test_date) values (?)", timestamp.to_s SQLite3::DATE_FORMAT_SECOND
|
||||||
db.exec "INSERT INTO test_table(test_date) values(current_timestamp)"
|
db.exec "INSERT INTO test_table (test_date) values (current_timestamp)"
|
||||||
db.query("SELECT test_date FROM test_table") do |rs|
|
db.query("SELECT test_date FROM test_table") do |rs|
|
||||||
rs.each do
|
rs.each do
|
||||||
rs.read(Time).should be_close(timestamp, 1.second)
|
rs.read(Time).should be_close(timestamp, 1.second)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue