Closed adam12 closed 1 year ago
Testing with sqlite://
as a connection string, the conn
object (receiving #execute
) is actually SQLite3::Database
, so I think the object provided is actually correct.
I think what's missing is an Extralite method that can fire off queries, and not care about their return value. Then inside Sequel::Extralite::Database
, we can define the private connection_execute_method
method which returns the symbol for the name of that method.
I think what's missing is an Extralite method that can fire off queries, and not care about their return value.
I'm thinking this isn't entirely accurate, now that I've fiddled with it a bit more. If you override connection_execute_method
to return :query
, it starts to work somewhat, but fails when trying to set up the migration table.
When setting up the migration table, it creates the table, then tries to alter the same table. Experimenting with this manually, performing a SELECT * FROM schema_info
with the SQLite adapter returns a fancy object. The same query when done with the Extralite adapter returns an empty Array. There's no way to determine the columns from there.
Maybe these are two separate issues. I'm not really sure where to proceed from here.
# test.rb
DB.create_table(:schema_info) { primary_key :id }
p DB.from(:schema_info).columns
$ sequel -E extralite:// test.rb
I, [2022-04-07T16:43:42.003466 #60279] INFO -- : (0.000028s) PRAGMA foreign_keys = 1
I, [2022-04-07T16:43:42.003516 #60279] INFO -- : (0.000004s) PRAGMA case_sensitive_like = 1
I, [2022-04-07T16:43:42.006106 #60279] INFO -- : (0.000164s) CREATE TABLE `schema_info` (`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT)
I, [2022-04-07T16:43:42.006221 #60279] INFO -- : (0.000016s) SELECT sqlite_version()
I, [2022-04-07T16:43:42.006309 #60279] INFO -- : (0.000012s) SELECT * FROM `schema_info` LIMIT 0
[]
$ sequel -E sqlite:// test.rb
I, [2022-04-07T16:43:17.355544 #60128] INFO -- : (0.000251s) PRAGMA foreign_keys = 1
I, [2022-04-07T16:43:17.355611 #60128] INFO -- : (0.000011s) PRAGMA case_sensitive_like = 1
I, [2022-04-07T16:43:17.357938 #60128] INFO -- : (0.000203s) CREATE TABLE `schema_info` (`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT)
I, [2022-04-07T16:43:17.358107 #60128] INFO -- : (0.000063s) SELECT sqlite_version()
I, [2022-04-07T16:43:17.358238 #60128] INFO -- : (0.000025s) SELECT * FROM `schema_info` LIMIT 0
[:id]
Could you give a script that reproduces this?
Could you give a script that reproduces this?
Here's one for the migrations. The missing columns are above.
#!/usr/bin/env ruby
require "bundler/inline"
require "tmpdir"
gemfile do
source "https://rubygems.org"
gem "sequel"
gem "extralite"
end
Dir.mktmpdir("extralite-migration") do |dir|
File.write(dir + "/001_migrate.rb", <<~RUBY)
Sequel.migration do
change do
create_table(:foobars) { primary_key :id }
end
end
RUBY
Sequel.extension :migration
DB = Sequel.connect("extralite://")
Sequel::Migrator.run(DB, dir)
end
At a cursory glance, the
conn
instance being called as the receiver ofexecute
is not an instance ofSequel::Extralite::Database
, butExtralite::Database
.