torque-postgresql 2.1.2 → 2.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 83fb6f6620a916f7ef85af51f4ba4fa6e2a1c6b3597ee5884466e4d46b6544c6
4
- data.tar.gz: 7503abd9ce29bd38349d88527502abc51182bb5e158e0f1960b71817d65cd559
3
+ metadata.gz: '09e539b25b952fb4d48bd092a90bae032ad8c26f1584cc5a704cdf96985b1e7e'
4
+ data.tar.gz: d79aa047ac44dc47a25979f71a0b46dfcbdc573f28d18bfcccbcb59b0a693c7b
5
5
  SHA512:
6
- metadata.gz: 13c371dccc04ee5663e2d249a443f398005a1d2e2cabea904c03f34c379ee4119c5ec5c7edeee52ef009d5223df9b514b6444b1ffeff9fc3231adbba93aebd5a
7
- data.tar.gz: c8308c9290b8bac1ee2d990ec64e128cdeed903d09dbc391b23eb5867930c41febc1affaf043840c81675642bebd027e1a6bdf7400c4375c23cfe111496ee174
6
+ metadata.gz: e2f75f66a5e0bed5f14006ff4ffd8e32f96bbe17f18ff4603c0706301c87114a1880b1a8f7bd530501d95c8f6dc10c563af6da5a2ba5f4414a31115c5510ca0f
7
+ data.tar.gz: 930b6381e8e920a274c411c2ba8abfe96a5b8462227c51dbf5ee9f2a41ac88b6f3a3946d4e49cab0017bb271c176d58c37690e5e646b8536476b83a1cba5c62b
@@ -70,7 +70,11 @@ module Torque
70
70
 
71
71
  # Returns all values that an enum type can have.
72
72
  def enum_values(name)
73
- select_values("SELECT unnest(enum_range(NULL::#{name}))", 'SCHEMA')
73
+ select_values(<<-SQL.squish, 'SCHEMA')
74
+ SELECT enumlabel FROM pg_enum
75
+ WHERE enumtypid = #{quote(name)}::regtype::oid
76
+ ORDER BY enumsortorder
77
+ SQL
74
78
  end
75
79
 
76
80
  # Rewrite the method that creates tables to easily accept extra options
@@ -40,7 +40,7 @@ module Torque
40
40
 
41
41
  pg_class = ::Arel::Table.new('pg_class')
42
42
  source = ::Arel::Table.new(subclass.table_name, as: 'source')
43
- quoted_id = ::Arel::Nodes::Quoted.new(self.class.connection.quote(id))
43
+ quoted_id = ::Arel::Nodes::Quoted.new(id)
44
44
 
45
45
  query = ::Arel::SelectManager.new(pg_class)
46
46
  query.join(source).on(pg_class['oid'].eq(source['tableoid']))
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Torque
4
4
  module PostgreSQL
5
- VERSION = '2.1.2'
5
+ VERSION = '2.1.3'
6
6
  end
7
7
  end
@@ -0,0 +1,3 @@
1
+ class Question < ActiveRecord::Base
2
+ self.implicit_order_column = 'created_at'
3
+ end
@@ -0,0 +1,2 @@
1
+ class QuestionSelect < Question
2
+ end
data/spec/schema.rb CHANGED
@@ -11,13 +11,14 @@
11
11
  # It's strongly recommended that you check this file into your version control system.
12
12
 
13
13
  begin
14
- version = 70
14
+ version = 73
15
15
 
16
16
  raise SystemExit if ActiveRecord::Migrator.current_version == version
17
17
  ActiveRecord::Schema.define(version: version) do
18
18
  self.verbose = false
19
19
 
20
20
  # These are extensions that must be enabled in order to support this database
21
+ enable_extension "pgcrypto"
21
22
  enable_extension "plpgsql"
22
23
 
23
24
  # These are user-defined types used on this database
@@ -125,6 +126,12 @@ begin
125
126
  t.datetime "updated_at", null: false
126
127
  end
127
128
 
129
+ create_table "questions", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
130
+ t.string "title"
131
+ t.datetime "created_at", null: false
132
+ t.datetime "updated_at", null: false
133
+ end
134
+
128
135
  create_table "activity_books", force: :cascade, inherits: :activities do |t|
129
136
  t.text "description"
130
137
  t.string "url"
@@ -139,6 +146,10 @@ begin
139
146
 
140
147
  create_table "activity_post_samples", force: :cascade, inherits: :activity_posts
141
148
 
149
+ create_table "question_selects", force: :cascade, inherits: :questions do |t|
150
+ t.string "options", array: true
151
+ end
152
+
142
153
  # create_table "activity_blanks", force: :cascade, inherits: :activities
143
154
 
144
155
  # create_table "activity_images", force: :cascade, inherits: [:activities, :images]
@@ -387,10 +387,10 @@ RSpec.describe 'TableInheritance' do
387
387
  base.create(title: 'Activity test')
388
388
  child.create(title: 'Activity book')
389
389
  other.create(name: 'An author name')
390
+ base.instance_variable_set(:@casted_dependents, nil)
390
391
  end
391
392
 
392
393
  it 'does not affect normal records' do
393
- base.instance_variable_set(:@casted_dependents, {})
394
394
  expect(base.first.cast_record).to be_a(base)
395
395
  expect(child.first.cast_record).to be_a(child)
396
396
  expect(other.first.cast_record).to be_a(other)
@@ -408,9 +408,28 @@ RSpec.describe 'TableInheritance' do
408
408
  end
409
409
 
410
410
  it 'does trigger record casting when accessed through inheritance' do
411
- base.instance_variable_set(:@casted_dependents, nil)
412
411
  expect(base.second.cast_record).to eql(child.first)
413
412
  end
413
+
414
+ context 'using uuid' do
415
+ let(:base) { Question }
416
+ let(:child) { QuestionSelect }
417
+
418
+ before :each do
419
+ base.create(title: 'Simple question')
420
+ child.create(title: 'Select question')
421
+ base.instance_variable_set(:@casted_dependents, nil)
422
+ end
423
+
424
+ it 'does not affect normal records' do
425
+ expect(base.first.cast_record).to be_a(base)
426
+ expect(child.first.cast_record).to be_a(child)
427
+ end
428
+
429
+ it 'does trigger record casting when accessed through inheritance' do
430
+ expect(base.second.cast_record).to eql(child.first)
431
+ end
432
+ end
414
433
  end
415
434
  end
416
435
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: torque-postgresql
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Silva
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-04 00:00:00.000000000 Z
11
+ date: 2021-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -262,6 +262,8 @@ files:
262
262
  - spec/models/guest_comment.rb
263
263
  - spec/models/item.rb
264
264
  - spec/models/post.rb
265
+ - spec/models/question.rb
266
+ - spec/models/question_select.rb
265
267
  - spec/models/tag.rb
266
268
  - spec/models/text.rb
267
269
  - spec/models/time_keeper.rb
@@ -305,55 +307,57 @@ required_rubygems_version: !ruby/object:Gem::Requirement
305
307
  - !ruby/object:Gem::Version
306
308
  version: 1.8.11
307
309
  requirements: []
308
- rubygems_version: 3.2.14
310
+ rubygems_version: 3.1.2
309
311
  signing_key:
310
312
  specification_version: 4
311
313
  summary: ActiveRecord extension to access PostgreSQL advanced resources
312
314
  test_files:
313
- - spec/models/activity_post/sample.rb
315
+ - spec/en.yml
316
+ - spec/factories/authors.rb
317
+ - spec/factories/comments.rb
318
+ - spec/factories/item.rb
319
+ - spec/factories/posts.rb
320
+ - spec/factories/tags.rb
321
+ - spec/factories/texts.rb
322
+ - spec/factories/users.rb
323
+ - spec/factories/videos.rb
324
+ - spec/mocks/cache_query.rb
325
+ - spec/mocks/create_table.rb
314
326
  - spec/models/activity.rb
327
+ - spec/models/activity_book.rb
328
+ - spec/models/activity_post.rb
329
+ - spec/models/activity_post/sample.rb
315
330
  - spec/models/author.rb
316
331
  - spec/models/author_journalist.rb
317
332
  - spec/models/comment.rb
318
333
  - spec/models/course.rb
319
- - spec/models/post.rb
320
- - spec/models/text.rb
321
- - spec/models/user.rb
322
- - spec/models/activity_book.rb
323
- - spec/models/activity_post.rb
324
334
  - spec/models/geometry.rb
325
335
  - spec/models/guest_comment.rb
336
+ - spec/models/item.rb
337
+ - spec/models/post.rb
326
338
  - spec/models/tag.rb
339
+ - spec/models/text.rb
327
340
  - spec/models/time_keeper.rb
341
+ - spec/models/user.rb
328
342
  - spec/models/video.rb
329
- - spec/models/item.rb
330
- - spec/factories/authors.rb
331
- - spec/factories/comments.rb
332
- - spec/factories/posts.rb
333
- - spec/factories/tags.rb
334
- - spec/factories/texts.rb
335
- - spec/factories/users.rb
336
- - spec/factories/videos.rb
337
- - spec/factories/item.rb
338
- - spec/tests/geometric_builder_spec.rb
343
+ - spec/models/question.rb
344
+ - spec/models/question_select.rb
345
+ - spec/spec_helper.rb
339
346
  - spec/tests/arel_spec.rb
340
- - spec/tests/insert_all_spec.rb
341
- - spec/tests/enum_spec.rb
342
- - spec/tests/period_spec.rb
343
- - spec/tests/range_spec.rb
347
+ - spec/tests/auxiliary_statement_spec.rb
348
+ - spec/tests/belongs_to_many_spec.rb
344
349
  - spec/tests/collector_spec.rb
345
350
  - spec/tests/distinct_on_spec.rb
351
+ - spec/tests/enum_set_spec.rb
352
+ - spec/tests/enum_spec.rb
353
+ - spec/tests/geometric_builder_spec.rb
354
+ - spec/tests/has_many_spec.rb
355
+ - spec/tests/insert_all_spec.rb
346
356
  - spec/tests/interval_spec.rb
347
357
  - spec/tests/lazy_spec.rb
358
+ - spec/tests/period_spec.rb
348
359
  - spec/tests/quoting_spec.rb
360
+ - spec/tests/range_spec.rb
349
361
  - spec/tests/relation_spec.rb
350
- - spec/tests/auxiliary_statement_spec.rb
351
- - spec/tests/enum_set_spec.rb
352
- - spec/tests/has_many_spec.rb
353
- - spec/tests/belongs_to_many_spec.rb
354
362
  - spec/tests/table_inheritance_spec.rb
355
- - spec/mocks/cache_query.rb
356
- - spec/mocks/create_table.rb
357
- - spec/en.yml
358
- - spec/spec_helper.rb
359
363
  - spec/schema.rb