Sha256: baabd4bc225841b2f8a3fd46dcdcf2d0fc279ca362c251f24e0b99c6b6950f90
Contents?: true
Size: 1.82 KB
Versions: 1
Compression:
Stored size: 1.82 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe "Knjdbrevision" do it "should create a SQLite3 database with a table who is a bigint with primarykey and autoincr. It should then convert it to a normal integer and not try to change it afterwards." do require "knjdbrevision" require "knjrbfw" require "knj/autoload" require "tmpdir" db_path = "#{Dir.tmpdir}/knjdbrevision_test.sqlite3" begin db = Knj::Db.new( :type => "sqlite3", :return_keys => "symbols", :index_append_table_name => true, :path => db_path ) schema = { "tables" => { "test_table" => { "columns" => [ {"name" => "id", "type" => "bigint", "autoincr" => true, "primarykey" => true}, {"name" => "name", "type" => "varchar"} ] } } } dbrev = Knjdbrevision.new dbrev.init_db(schema, db) dbrev.init_db(schema, db) db.close db = Knj::Db.new( :type => "sqlite3", :return_keys => "symbols", :index_append_table_name => true, :path => db_path ) #Test autoincr is still working (if primarykey 'id' was converted to a bigint then it will not... knjdbrevision should not convert the primarykey to bigint on SQLite3... Specific bugfix.. if db.tables["test_table"].column("id").type != "int" raise "The primary ID was not of the 'int'-type." end db.insert("test_table", {"name" => "Kasper"}) db.q("SELECT * FROM test_table") do |d| if d[:id].to_i != 1 Knj::Php.print_r(d) raise "The ID was not 1 on the inserted row: '#{d[:id]}'." end end ensure File.unlink(db_path) if File.exists?(db_path) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
knjdbrevision-0.0.3 | spec/knjdbrevision_spec.rb |