Skip to content

Commit

Permalink
Specs for showing the multiple connections working.
Browse files Browse the repository at this point in the history
I'm seeing an issue with inserts on a different database causing
problems. I'll have to address that next.
  • Loading branch information
russ authored and anykeyh committed Jun 24, 2018
1 parent ec3f645 commit af91ef8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions spec/spec_helper.cr
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ def initdb
{% end %}
end

def init_secondary_db
system("echo \"DROP DATABASE IF EXISTS clear_secondary_spec;\" | psql -U postgres")
system("echo \"CREATE DATABASE clear_secondary_spec;\" | psql -U postgres")
system("echo \"CREATE TABLE models_post_stats (id serial PRIMARY KEY, post_id INTEGER);\" | psql -U postgres clear_secondary_spec")
system("echo \"INSERT INTO models_post_stats VALUES (1, 1);\" | psql -U postgres clear_secondary_spec")

Clear::SQL.init({
"deafult" => "postgres://postgres@localhost/clear_spec",
"secondary" => "postgres://postgres@localhost/clear_secondary_spec",
})
end

def reinit_migration_manager
Clear::Migration::Manager.instance.reinit!
end
Expand Down
2 changes: 1 addition & 1 deletion src/clear/sql/insert_query.cr
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Clear::SQL::InsertQuery
o = {} of String => ::Clear::SQL::Any

if @returning.nil?
Clear::SQL.execute(to_sql)
Clear::SQL.execute(self.connection_name, to_sql)
else
# return {} of String => ::Clear::SQL::Any
fetch { |x| o = x; break }
Expand Down

0 comments on commit af91ef8

Please sign in to comment.