Skip to content

Commit

Permalink
Trying to reproduce prepared statement error.
Browse files Browse the repository at this point in the history
  • Loading branch information
xtagon committed Sep 24, 2018
1 parent 8adb826 commit 4ea5b6e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
13 changes: 13 additions & 0 deletions spec/active_record/hierarchical_query_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@
let!(:child_5) { klass.create(parent: child_4, trait_id: trait_id) }

describe '#join_recursive' do
describe 'specifying a a UUID as the start_with ID and using depth, WHERE and ORDER' do
it "does not raise an error" do
relation = klass.join_recursive do |query|
query.
start_with(id: root.id) { select("0 depth") }.
select(query.prior[:depth] + 1, start_with: false).
connect_by(id: :parent_id)
end

relation.where(trait_id: 'trait').order("depth ASC").first
end
end

describe 'UNION clause' do
let(:options) { {} }
subject { klass.join_recursive(options) { connect_by(id: :parent_id) }.to_sql }
Expand Down
13 changes: 8 additions & 5 deletions spec/schema.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
ActiveRecord::Migration.verbose = false

ActiveRecord::Schema.define(version: 0) do
create_table :categories, force: true do |t|
t.column :parent_id, :integer
enable_extension 'uuid-ossp'
enable_extension 'pgcrypto'

create_table :categories, force: true, id: :uuid do |t|
t.column :parent_id, :uuid
t.column :trait_id, :string
t.column :name, :string
t.column :depth, :integer
t.column :position, :integer
end

create_table :articles, force: true do |t|
t.column :category_id, :integer
t.column :category_id, :uuid
t.column :title, :string
end

create_table :model_with_default_scopes, force: true do |t|
t.column :parent_id, :integer
create_table :model_with_default_scopes, force: true, id: :uuid do |t|
t.column :parent_id, :uuid
t.column :name, :string
end
end

0 comments on commit 4ea5b6e

Please sign in to comment.