sbf-dm-do-adapter 1.4.0.beta.1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dm-do-adapter.gemspec +2 -2
- data/lib/dm-do-adapter/adapter.rb +38 -35
- data/lib/dm-do-adapter/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16a04bde325413ace3bc643766937bc5289e7607fc1b1ef75453a7bb8265c37b
|
4
|
+
data.tar.gz: a73e33316d89daed37f90c15421d5f662cac23d8c7e6ed2f834a57c1aceb958c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3420ce790fd8c93c2718cf65ad73c4df1b00a44237d150b24c9ad5800f2e7ec7fbf455a77872196d967184f33cda1c79233db2075550911118a1f9a7d7fd3bbf
|
7
|
+
data.tar.gz: 9756624b873d2e32e4166597a05edcba3153bca2908d606965554aab2410b5b2678bceee4251e4e59aa89aa89b1a987795fbb60725f3f94c87e42364a9ef11ef
|
data/dm-do-adapter.gemspec
CHANGED
@@ -16,6 +16,6 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.version = DataMapper::DoAdapter::VERSION
|
17
17
|
gem.required_ruby_version = '>= 2.7.8'
|
18
18
|
|
19
|
-
gem.add_runtime_dependency('sbf-data_objects', ['~> 0.11
|
20
|
-
gem.add_runtime_dependency('sbf-dm-core', ['~> 1.3
|
19
|
+
gem.add_runtime_dependency('sbf-data_objects', ['~> 0.11'])
|
20
|
+
gem.add_runtime_dependency('sbf-dm-core', ['~> 1.3'])
|
21
21
|
end
|
@@ -14,7 +14,6 @@ module DataMapper
|
|
14
14
|
class DataObjectsAdapter < AbstractAdapter
|
15
15
|
extend Chainable
|
16
16
|
extend Deprecate
|
17
|
-
include SQL
|
18
17
|
|
19
18
|
SQL_FALSE = '1 = 0'.freeze
|
20
19
|
|
@@ -315,13 +314,13 @@ module DataMapper
|
|
315
314
|
IDENTIFIER_MAX_LENGTH = 128
|
316
315
|
|
317
316
|
# @api semipublic
|
318
|
-
def
|
317
|
+
def property_to_column_name(property, qualify)
|
319
318
|
column_name = ''
|
320
319
|
|
321
320
|
case qualify
|
322
|
-
|
321
|
+
when true
|
323
322
|
column_name << "#{quote_name(property.model.storage_name(name))}."
|
324
|
-
|
323
|
+
when String
|
325
324
|
column_name << "#{quote_name(qualify)}."
|
326
325
|
end
|
327
326
|
|
@@ -334,7 +333,7 @@ module DataMapper
|
|
334
333
|
# should overwrite this to return true.
|
335
334
|
#
|
336
335
|
# @api private
|
337
|
-
def
|
336
|
+
def supports_returning?
|
338
337
|
false
|
339
338
|
end
|
340
339
|
|
@@ -342,7 +341,7 @@ module DataMapper
|
|
342
341
|
# INSERT statements should overwrite this to return false.
|
343
342
|
#
|
344
343
|
# @api private
|
345
|
-
def
|
344
|
+
def supports_default_values?
|
346
345
|
true
|
347
346
|
end
|
348
347
|
|
@@ -351,7 +350,7 @@ module DataMapper
|
|
351
350
|
# @return [String] SELECT statement as a string
|
352
351
|
#
|
353
352
|
# @api private
|
354
|
-
def
|
353
|
+
def select_statement(query)
|
355
354
|
qualify = query.links.any?
|
356
355
|
fields = query.fields
|
357
356
|
order_by = query.order
|
@@ -375,7 +374,7 @@ module DataMapper
|
|
375
374
|
|
376
375
|
# default construction of LIMIT and OFFSET
|
377
376
|
# overriden by some adapters (currently Oracle and SQL Server)
|
378
|
-
def
|
377
|
+
def add_limit_offset!(statement, limit, offset, bind_values)
|
379
378
|
if limit
|
380
379
|
statement << ' LIMIT ?'
|
381
380
|
bind_values << limit
|
@@ -392,7 +391,7 @@ module DataMapper
|
|
392
391
|
# @return [String] INSERT statement as a string
|
393
392
|
#
|
394
393
|
# @api private
|
395
|
-
def
|
394
|
+
def insert_statement(model, properties, serial)
|
396
395
|
statement = "INSERT INTO #{quote_name(model.storage_name(name))} "
|
397
396
|
|
398
397
|
if supports_default_values? && properties.empty?
|
@@ -414,13 +413,13 @@ module DataMapper
|
|
414
413
|
|
415
414
|
# by default PostgreSQL syntax
|
416
415
|
# overrided in Oracle adapter
|
417
|
-
def
|
416
|
+
def default_values_clause
|
418
417
|
'DEFAULT VALUES'
|
419
418
|
end
|
420
419
|
|
421
420
|
# by default PostgreSQL syntax
|
422
421
|
# overrided in Oracle adapter
|
423
|
-
def
|
422
|
+
def returning_clause(serial)
|
424
423
|
" RETURNING #{quote_name(serial.field)}"
|
425
424
|
end
|
426
425
|
|
@@ -429,7 +428,7 @@ module DataMapper
|
|
429
428
|
# @return [String] UPDATE statement as a string
|
430
429
|
#
|
431
430
|
# @api private
|
432
|
-
def
|
431
|
+
def update_statement(properties, query)
|
433
432
|
model = query.model
|
434
433
|
name = self.name
|
435
434
|
|
@@ -452,7 +451,7 @@ module DataMapper
|
|
452
451
|
# @return [String] DELETE statement as a string
|
453
452
|
#
|
454
453
|
# @api private
|
455
|
-
def
|
454
|
+
def delete_statement(query)
|
456
455
|
model = query.model
|
457
456
|
name = self.name
|
458
457
|
|
@@ -475,8 +474,8 @@ module DataMapper
|
|
475
474
|
# list of fields as a string
|
476
475
|
#
|
477
476
|
# @api private
|
478
|
-
def
|
479
|
-
properties.map { |property|
|
477
|
+
def columns_statement(properties, qualify)
|
478
|
+
properties.map { |property| chainable_property_to_column_name(property, qualify) }.join(', ')
|
480
479
|
end
|
481
480
|
|
482
481
|
# Constructs joins clause
|
@@ -485,7 +484,7 @@ module DataMapper
|
|
485
484
|
# joins clause
|
486
485
|
#
|
487
486
|
# @api private
|
488
|
-
def
|
487
|
+
def join_statement(query, bind_values, qualify)
|
489
488
|
statements = []
|
490
489
|
join_bind_values = []
|
491
490
|
|
@@ -519,13 +518,13 @@ module DataMapper
|
|
519
518
|
statements.join(' ')
|
520
519
|
end
|
521
520
|
|
522
|
-
def
|
521
|
+
def add_join_conditions(relationship, target_alias, source_alias, statements)
|
523
522
|
statements << relationship.target_key.zip(relationship.source_key).map do |target_property, source_property|
|
524
523
|
"#{property_to_column_name(target_property, target_alias)} = #{property_to_column_name(source_property, source_alias)}"
|
525
524
|
end.join(' AND ')
|
526
525
|
end
|
527
526
|
|
528
|
-
def
|
527
|
+
def add_extra_join_conditions(relationship, target_alias, statements, bind_values)
|
529
528
|
conditions = DataMapper.repository(name).scope do
|
530
529
|
relationship.target_model.all(relationship.query).query.conditions
|
531
530
|
end
|
@@ -543,7 +542,7 @@ module DataMapper
|
|
543
542
|
# where clause
|
544
543
|
#
|
545
544
|
# @api private
|
546
|
-
def
|
545
|
+
def conditions_statement(conditions, qualify = false)
|
547
546
|
case conditions
|
548
547
|
when Query::Conditions::NotOperation then negate_operation(conditions.operand, qualify)
|
549
548
|
when Query::Conditions::AbstractOperation then operation_statement(conditions, qualify)
|
@@ -555,12 +554,12 @@ module DataMapper
|
|
555
554
|
end
|
556
555
|
|
557
556
|
# @api private
|
558
|
-
def
|
557
|
+
def supports_subquery?(*)
|
559
558
|
true
|
560
559
|
end
|
561
560
|
|
562
561
|
# @api private
|
563
|
-
def
|
562
|
+
def subquery(query, subject, qualify)
|
564
563
|
source_key, target_key = subquery_keys(subject)
|
565
564
|
|
566
565
|
if query.repository.name == name && supports_subquery?(query, source_key, target_key, qualify)
|
@@ -571,7 +570,7 @@ module DataMapper
|
|
571
570
|
end
|
572
571
|
|
573
572
|
# @api private
|
574
|
-
def
|
573
|
+
def subquery_statement(query, source_key, target_key, qualify)
|
575
574
|
query = subquery_query(query, source_key)
|
576
575
|
select_statement, bind_values = select_statement(query)
|
577
576
|
|
@@ -587,7 +586,7 @@ module DataMapper
|
|
587
586
|
end
|
588
587
|
|
589
588
|
# @api private
|
590
|
-
def
|
589
|
+
def subquery_execute(query, source_key, target_key, qualify)
|
591
590
|
query = subquery_query(query, source_key)
|
592
591
|
sources = query.model.all(query)
|
593
592
|
conditions = Query.target_conditions(sources, source_key, target_key)
|
@@ -600,7 +599,7 @@ module DataMapper
|
|
600
599
|
end
|
601
600
|
|
602
601
|
# @api private
|
603
|
-
def
|
602
|
+
def subquery_keys(subject)
|
604
603
|
case subject
|
605
604
|
when Associations::Relationship
|
606
605
|
relationship = subject.inverse
|
@@ -611,7 +610,7 @@ module DataMapper
|
|
611
610
|
end
|
612
611
|
|
613
612
|
# @api private
|
614
|
-
def
|
613
|
+
def subquery_query(query, source_key)
|
615
614
|
# force unique to be false because PostgreSQL has a problem with
|
616
615
|
# subselects that contain a GROUP BY with different columns
|
617
616
|
# than the outer-most query
|
@@ -626,7 +625,7 @@ module DataMapper
|
|
626
625
|
# order clause
|
627
626
|
#
|
628
627
|
# @api private
|
629
|
-
def
|
628
|
+
def order_statement(order, qualify)
|
630
629
|
statements = order.map do |direction|
|
631
630
|
statement = property_to_column_name(direction.target, qualify)
|
632
631
|
statement << ' DESC' if direction.operator == :desc
|
@@ -637,14 +636,14 @@ module DataMapper
|
|
637
636
|
end
|
638
637
|
|
639
638
|
# @api private
|
640
|
-
def
|
639
|
+
def negate_operation(operand, qualify)
|
641
640
|
statement, bind_values = conditions_statement(operand, qualify)
|
642
641
|
statement = "NOT(#{statement})" unless statement.nil?
|
643
642
|
[ statement, bind_values ]
|
644
643
|
end
|
645
644
|
|
646
645
|
# @api private
|
647
|
-
def
|
646
|
+
def operation_statement(operation, qualify)
|
648
647
|
statements = []
|
649
648
|
bind_values = []
|
650
649
|
|
@@ -670,7 +669,7 @@ module DataMapper
|
|
670
669
|
# comparison clause
|
671
670
|
#
|
672
671
|
# @api private
|
673
|
-
def
|
672
|
+
def comparison_statement(comparison, qualify)
|
674
673
|
subject = comparison.subject
|
675
674
|
value = comparison.value
|
676
675
|
|
@@ -743,7 +742,7 @@ module DataMapper
|
|
743
742
|
end
|
744
743
|
end
|
745
744
|
|
746
|
-
def
|
745
|
+
def comparison_operator(comparison)
|
747
746
|
subject = comparison.subject
|
748
747
|
value = comparison.value
|
749
748
|
|
@@ -760,12 +759,12 @@ module DataMapper
|
|
760
759
|
end
|
761
760
|
|
762
761
|
# @api private
|
763
|
-
def
|
762
|
+
def equality_operator(property, operand)
|
764
763
|
operand.nil? ? 'IS' : '='
|
765
764
|
end
|
766
765
|
|
767
766
|
# @api private
|
768
|
-
def
|
767
|
+
def include_operator(property, operand)
|
769
768
|
case operand
|
770
769
|
when Array then 'IN'
|
771
770
|
when Range then 'BETWEEN'
|
@@ -773,20 +772,24 @@ module DataMapper
|
|
773
772
|
end
|
774
773
|
|
775
774
|
# @api private
|
776
|
-
def
|
775
|
+
def regexp_operator(operand)
|
777
776
|
'~'
|
778
777
|
end
|
779
778
|
|
780
779
|
# @api private
|
781
|
-
def
|
780
|
+
def like_operator(operand)
|
782
781
|
'LIKE'
|
783
782
|
end
|
784
783
|
|
785
784
|
# @api private
|
786
|
-
def
|
785
|
+
def quote_name(name)
|
787
786
|
"\"#{name[0, self.class::IDENTIFIER_MAX_LENGTH].gsub('"', '""')}\""
|
788
787
|
end
|
788
|
+
|
789
789
|
end
|
790
|
+
|
791
|
+
include SQL
|
792
|
+
|
790
793
|
end
|
791
794
|
|
792
795
|
const_added(:DataObjectsAdapter)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sbf-dm-do-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.0
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- opensource_firespring
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sbf-data_objects
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.11
|
19
|
+
version: '0.11'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.11
|
26
|
+
version: '0.11'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: sbf-dm-core
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.3
|
33
|
+
version: '1.3'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.3
|
40
|
+
version: '1.3'
|
41
41
|
description: A unified Ruby API for popular databases.
|
42
42
|
email:
|
43
43
|
- opensource@firespring.com
|
@@ -76,9 +76,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
76
76
|
version: 2.7.8
|
77
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
|
-
- - "
|
79
|
+
- - ">="
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version:
|
81
|
+
version: '0'
|
82
82
|
requirements: []
|
83
83
|
rubygems_version: 3.4.10
|
84
84
|
signing_key:
|