rom-sql 3.6.4 → 4.0.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -48
  3. data/LICENSE +1 -1
  4. data/README.md +1 -1
  5. data/lib/rom/plugins/relation/sql/auto_restrictions.rb +11 -10
  6. data/lib/rom/plugins/relation/sql/default_views.rb +75 -0
  7. data/lib/rom/plugins/relation/sql/instrumentation.rb +8 -13
  8. data/lib/rom/plugins/relation/sql/postgres/explain.rb +4 -4
  9. data/lib/rom/plugins/relation/sql/postgres/full_text_search.rb +18 -16
  10. data/lib/rom/plugins/relation/sql/postgres/streaming.rb +12 -9
  11. data/lib/rom/sql/associations/many_to_many.rb +7 -7
  12. data/lib/rom/sql/associations/many_to_one.rb +3 -3
  13. data/lib/rom/sql/associations/one_to_many.rb +3 -3
  14. data/lib/rom/sql/associations/one_to_one.rb +1 -1
  15. data/lib/rom/sql/associations/one_to_one_through.rb +1 -1
  16. data/lib/rom/sql/associations/self_ref.rb +1 -1
  17. data/lib/rom/sql/associations.rb +5 -5
  18. data/lib/rom/sql/attribute.rb +9 -9
  19. data/lib/rom/sql/attribute_aliasing.rb +2 -3
  20. data/lib/rom/sql/commands/create.rb +5 -4
  21. data/lib/rom/sql/commands/delete.rb +2 -2
  22. data/lib/rom/sql/commands/update.rb +5 -4
  23. data/lib/rom/sql/commands.rb +4 -4
  24. data/lib/rom/sql/dsl.rb +3 -3
  25. data/lib/rom/sql/errors.rb +3 -3
  26. data/lib/rom/sql/extensions/active_support_notifications.rb +4 -4
  27. data/lib/rom/sql/extensions/mysql/type_builder.rb +5 -5
  28. data/lib/rom/sql/extensions/mysql.rb +1 -1
  29. data/lib/rom/sql/extensions/postgres/commands.rb +13 -31
  30. data/lib/rom/sql/extensions/postgres/type_builder.rb +28 -31
  31. data/lib/rom/sql/extensions/postgres/type_serializer.rb +24 -25
  32. data/lib/rom/sql/extensions/postgres/types/array.rb +4 -4
  33. data/lib/rom/sql/extensions/postgres/types/array_types.rb +1 -1
  34. data/lib/rom/sql/extensions/postgres/types/geometric.rb +27 -27
  35. data/lib/rom/sql/extensions/postgres/types/json.rb +9 -9
  36. data/lib/rom/sql/extensions/postgres/types/ltree.rb +61 -34
  37. data/lib/rom/sql/extensions/postgres/types/network.rb +4 -17
  38. data/lib/rom/sql/extensions/postgres/types/range.rb +25 -25
  39. data/lib/rom/sql/extensions/postgres/types.rb +14 -14
  40. data/lib/rom/sql/extensions/postgres.rb +6 -6
  41. data/lib/rom/sql/extensions/rails_log_subscriber.rb +6 -21
  42. data/lib/rom/sql/extensions/sqlite/types.rb +1 -1
  43. data/lib/rom/sql/extensions/sqlite.rb +2 -2
  44. data/lib/rom/sql/extensions.rb +6 -6
  45. data/lib/rom/sql/foreign_key.rb +3 -1
  46. data/lib/rom/sql/function.rb +18 -22
  47. data/lib/rom/sql/gateway.rb +44 -17
  48. data/lib/rom/sql/group_dsl.rb +1 -1
  49. data/lib/rom/sql/index.rb +2 -0
  50. data/lib/rom/sql/join_dsl.rb +1 -1
  51. data/lib/rom/sql/mapper_compiler.rb +2 -2
  52. data/lib/rom/sql/migration/migrator.rb +11 -11
  53. data/lib/rom/sql/migration/runner.rb +3 -3
  54. data/lib/rom/sql/migration/schema_diff.rb +7 -8
  55. data/lib/rom/sql/migration/writer.rb +12 -12
  56. data/lib/rom/sql/migration.rb +4 -8
  57. data/lib/rom/sql/order_dsl.rb +1 -1
  58. data/lib/rom/sql/plugin/associates.rb +49 -11
  59. data/lib/rom/sql/plugin/pagination.rb +5 -3
  60. data/lib/rom/sql/plugin/schema_indexes.rb +35 -0
  61. data/lib/rom/sql/plugins.rb +9 -6
  62. data/lib/rom/sql/projection_dsl.rb +4 -4
  63. data/lib/rom/sql/rake_task.rb +2 -2
  64. data/lib/rom/sql/relation/reading.rb +34 -27
  65. data/lib/rom/sql/relation/writing.rb +11 -10
  66. data/lib/rom/sql/relation.rb +57 -89
  67. data/lib/rom/sql/restriction_dsl.rb +2 -2
  68. data/lib/rom/sql/schema/attributes_inferrer.rb +3 -3
  69. data/lib/rom/sql/schema/dsl.rb +4 -2
  70. data/lib/rom/sql/schema/index_dsl.rb +3 -5
  71. data/lib/rom/sql/schema/inferrer.rb +25 -23
  72. data/lib/rom/sql/schema/type_builder.rb +2 -2
  73. data/lib/rom/sql/schema.rb +9 -21
  74. data/lib/rom/sql/spec/support.rb +5 -5
  75. data/lib/rom/sql/tasks/migration_tasks.rake +13 -21
  76. data/lib/rom/sql/transaction.rb +4 -2
  77. data/lib/rom/sql/type_extensions.rb +3 -1
  78. data/lib/rom/sql/type_serializer.rb +10 -10
  79. data/lib/rom/sql/types.rb +4 -4
  80. data/lib/rom/sql/version.rb +1 -1
  81. data/lib/rom/sql/wrap.rb +1 -1
  82. data/lib/rom/sql.rb +13 -12
  83. data/lib/rom/types/values.rb +2 -2
  84. data/lib/rom-sql.rb +1 -1
  85. metadata +13 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a3a5d8acca77c2d148be8cdfc268eee1851619947eed8923d6b174a05c199a32
4
- data.tar.gz: 3c3780102c9055ceada519a2638761b90b43ad3f1b8d6f71063c2aee6817f2f4
3
+ metadata.gz: a6a932fc53433b38ce71cb363a4e29e4fef4f949849f47d2b4f2bb2bc8e6cf35
4
+ data.tar.gz: da89ced65458c9facaffe74e365eb8bf81f0ee18718aba6b2e92da0717ef0f5c
5
5
  SHA512:
6
- metadata.gz: 452127dc2b154c8e513efc34e698c8fe4de0be2de9e21746b584fa14cb3642d3a2ce3ba0d085db54fa6153a1b796a5fd422fce6e24095cd8588028ed7924670d
7
- data.tar.gz: d8fec6ff6f5ad4ce1d37eca0a51a4ed0f412d8ef611ca29fbc41c285ff46ec419fd0e94cf17ebc63a4c7314791514de71400200826540d2aa5a366b21b7427ba
6
+ metadata.gz: e6648c04e92f83b529942d6b46587e577523b27aba2bfd0cdacfd37c69a8594ca0bf63df564d8f13ec288dece1e837e9163eab96eeb068b455dab00567b9fe44
7
+ data.tar.gz: ef78eaaacc3810bc7accf3e3fa5fc38df951f20b4df0ed57dd333adba2a90d450aebf84318d81541b2770731f1b4af21289ad66040c3d822ba4e240dd0bfb056
data/CHANGELOG.md CHANGED
@@ -1,66 +1,29 @@
1
1
  <!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
2
2
 
3
- ## 3.6.4 2024-07-01
3
+ ## 4.0.0.alpha1 2022-04-15
4
4
 
5
+ See [rom 6.0 upgrade guide](https://github.com/rom-rb/rom/wiki/6.0-Upgrade-Guide).
5
6
 
6
- ### Fixed
7
-
8
- - Excessive logging when same gateway is shared between multiple containers (@flash-gordon)
9
- - Warning about using color option from active-support log subscriber (@flash-gordon + @bendangelo)
10
-
11
-
12
- [Compare v3.6.3...v3.6.4](https://github.com/rom-rb/rom-sql/compare/v3.6.3...v3.6.4)
13
-
14
- ## 3.6.3 2024-05-06
15
-
16
-
17
- ### Fixed
18
-
19
- - Fix using `.filter` with a block for aggregate functions (@flash-gordon)
20
-
21
-
22
- [Compare v3.6.2...v3.6.3](https://github.com/rom-rb/rom-sql/compare/v3.6.2...v3.6.3)
23
-
24
- ## 3.6.2 2024-01-09
25
-
26
-
27
- ### Fixed
28
-
29
- - Fix Hash.new warning in Ruby 3.3 (@flash-gordon)
30
-
31
-
32
- [Compare v3.6.1...v3.6.2](https://github.com/rom-rb/rom-sql/compare/v3.6.1...v3.6.2)
33
-
34
- ## 3.6.1 2022-11-22
7
+ ### Changed
35
8
 
36
- ### Fixed
9
+ - [internal] all plugins have been ported to the new API (via #402) (@solnic)
10
+ - [internal] `:default_views` plugin was added and it's enabled by default (via #402) (@solnic)
11
+ - [internal] `indexes` schema DSL is now a plugin called `:schema_indexes` (via #402) (@solnic)
12
+ - [internal] `Gateway#command` is now used to instantiate sql-specific commands (via #402) (@solnic)
37
13
 
38
- - Mapping of cidr types in PostgreSQL to IPAddr values (@flash-gordon)
14
+ [Compare v3.5.0...v4.0.0.alpha1](https://github.com/rom-rb/rom-sql/compare/v3.5.0...v4.0.0.alpha1)
39
15
 
40
- [Compare v3.6.0...v3.6.1](https://github.com/rom-rb/rom-sql/compare/v3.6.0...v3.6.1)
16
+ ## 3.5.0 2021-03-26
41
17
 
42
- ## 3.6.0 2022-11-11
43
18
 
44
19
  ### Added
45
20
 
46
- - Add ROM::SQL::RakeSupport.migration_options for passing custom options to migrator (@wuarmin)
47
-
48
- ### Changed
49
-
50
- - Upgraded to the latest versions of dry-rb dependencies, compatible with rom 5.3 (@flash-gordon)
51
-
52
- [Compare v3.5.0...v3.6.0](https://github.com/rom-rb/rom-sql/compare/v3.5.0...v3.6.0)
53
-
54
- ## 3.5.0 2021-03-26
55
-
21
+ - Support for using partial indixes in PG upsert commands (issue #394 fixed via #395) (@smaximov)
56
22
 
57
23
  ### Fixed
58
24
 
59
- - Restored the fix for #390 that was lost by an accident in 3.3.3 and 3.4.0 (@solnic)
60
-
61
- ### Added
25
+ - Restore the fix for #390 that was lost by an accident in 3.3.3 and 3.4.0 (@solnic)
62
26
 
63
- - Support for using partial indixes in PG upsert commands (issue #394 fixed via #395) (@smaximov)
64
27
 
65
28
  [Compare v3.4.0...v3.5.0](https://github.com/rom-rb/rom-sql/compare/v3.4.0...v3.5.0)
66
29
 
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015-2020 rom-rb team
3
+ Copyright (c) 2015-2021 rom-rb team
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
data/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
  [![CI Status](https://github.com/rom-rb/rom-sql/workflows/ci/badge.svg)][actions]
11
11
  [![Codacy Badge](https://api.codacy.com/project/badge/Grade/8e2cbaf78af44185876c8fa41540d7ea)][codacy]
12
12
  [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/8e2cbaf78af44185876c8fa41540d7ea)][codacy]
13
- [![Inline docs](http://inch-ci.org/github/rom-rb/rom-sql.svg?branch=master)][inchpages]
13
+ [![Inline docs](http://inch-ci.org/github/rom-rb/rom-sql.svg?branch=main)][inchpages]
14
14
 
15
15
  ## Links
16
16
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rom/support/notifications'
3
+ require "dry/effects"
4
4
 
5
5
  module ROM
6
6
  module Plugins
@@ -27,15 +27,16 @@ module ROM
27
27
  #
28
28
  # @api public
29
29
  module AutoRestrictions
30
- extend Notifications::Listener
30
+ extend Dry::Effects.Reader(:registry)
31
31
 
32
- subscribe('configuration.relations.schema.set', adapter: :sql) do |event|
33
- schema = event[:schema]
34
- relation = event[:relation]
32
+ # @api private
33
+ def self.apply(target, **)
34
+ methods, mod = AutoRestrictions.restriction_methods(registry.schemas.canonical(target))
35
35
 
36
- methods, mod = AutoRestrictions.restriction_methods(schema)
37
- relation.include(mod)
38
- methods.each { |meth| relation.auto_curry(meth) }
36
+ target.class_eval do
37
+ include(mod)
38
+ methods.each { |meth| auto_curry(meth) }
39
+ end
39
40
  end
40
41
 
41
42
  # @api private
@@ -46,7 +47,7 @@ module ROM
46
47
  next if index.partial?
47
48
 
48
49
  attributes = index.to_a
49
- meth_name = :"by_#{ attributes.map(&:name).join('_and_') }"
50
+ meth_name = :"by_#{attributes.map(&:name).join("_and_")}"
50
51
 
51
52
  next if generated.include?(meth_name)
52
53
 
@@ -78,7 +79,7 @@ module ROM
78
79
  end
79
80
 
80
81
  ROM.plugins do
81
- adapter :sql do
82
+ adapter(:sql) do
82
83
  register :auto_restrictions, ROM::Plugins::Relation::SQL::AutoRestrictions, type: :relation
83
84
  end
84
85
  end
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dry/effects"
4
+
5
+ module ROM
6
+ module Plugins
7
+ module Relation
8
+ module SQL
9
+ # @api private
10
+ module DefaultViews
11
+ extend Dry::Effects.Reader(:registry)
12
+
13
+ # @api private
14
+ def self.apply(target, **)
15
+ define_default_views!(target, registry.schemas.canonical(target))
16
+ end
17
+
18
+ # @api private
19
+ def self.define_default_views!(target, schema)
20
+ if schema.primary_key.size > 1
21
+ # @!method by_pk(val1, val2)
22
+ # Return a relation restricted by its composite primary key
23
+ #
24
+ # @param [Array] args A list with composite pk values
25
+ #
26
+ # @return [SQL::Relation]
27
+ #
28
+ # @api public
29
+ target.class_eval <<-RUBY, __FILE__, __LINE__ + 1
30
+ undef :by_pk if method_defined?(:by_pk)
31
+
32
+ def by_pk(#{schema.primary_key.map(&:name).join(", ")})
33
+ where(#{schema.primary_key.map { |attr| "schema.canonical[:#{attr.name}] => #{attr.name}" }.join(", ")})
34
+ end
35
+ RUBY
36
+ else
37
+ # @!method by_pk(pk)
38
+ # Return a relation restricted by its primary key
39
+ #
40
+ # @param [Object] pk The primary key value
41
+ #
42
+ # @return [SQL::Relation]
43
+ #
44
+ # @api public
45
+ target.class_eval <<-RUBY, __FILE__, __LINE__ + 1
46
+ undef :by_pk if method_defined?(:by_pk)
47
+
48
+ def by_pk(pk)
49
+ if primary_key.nil?
50
+ raise MissingPrimaryKeyError.new(
51
+ "Missing primary key for :\#{schema.name}"
52
+ )
53
+ end
54
+ where(schema.canonical[schema.canonical.primary_key_name].qualified => pk)
55
+ end
56
+ RUBY
57
+ end
58
+ end
59
+
60
+ # @api private
61
+ def self.primary_key_columns(db, table)
62
+ names = db.respond_to?(:primary_key) ? Array(db.primary_key(table)) : [:id]
63
+ names.map { |col| :"#{table}__#{col}" }
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+
71
+ ROM.plugins do
72
+ adapter(:sql) do
73
+ register :default_views, ROM::Plugins::Relation::SQL::DefaultViews, type: :relation
74
+ end
75
+ end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "dry/effects"
4
+
3
5
  module ROM
4
6
  module Plugins
5
7
  module Relation
@@ -26,20 +28,14 @@ module ROM
26
28
  #
27
29
  # @api public
28
30
  module Instrumentation
29
- extend Notifications::Listener
30
-
31
- subscribe('configuration.relations.registry.created') do |event|
32
- registry = event[:registry]
31
+ extend Dry::Effects.Reader(:registry)
33
32
 
34
- relations = registry.select { |_, r| r.adapter == :sql && r.respond_to?(:notifications) }.to_h
35
- db_notifications = relations.values.map { |r| [r.dataset.db, r.notifications] }.uniq.to_h
33
+ def self.apply(target, notifications:, **)
34
+ db = registry.gateways[target.config.component.gateway].connection
36
35
 
37
- db_notifications.each do |db, notifications|
38
- next if db.respond_to?(:rom_instrumentation?)
36
+ return if db.respond_to?(:rom_instrumentation?)
39
37
 
40
- instrumenter = Instrumenter.new(db.database_type, notifications)
41
- db.extend(instrumenter)
42
- end
38
+ db.extend(Instrumenter.new(db.database_type, notifications))
43
39
  end
44
40
 
45
41
  # This stateful module is used to extend database connection objects
@@ -59,7 +55,6 @@ module ROM
59
55
  # @api private
60
56
  def initialize(name, notifications)
61
57
  super()
62
-
63
58
  @name = name
64
59
  @notifications = notifications
65
60
  define_log_connection_yield
@@ -96,7 +91,7 @@ module ROM
96
91
  end
97
92
 
98
93
  ROM.plugins do
99
- adapter :sql do
94
+ adapter(:sql) do
100
95
  register :instrumentation, ROM::Plugins::Relation::SQL::Instrumentation, type: :relation
101
96
  end
102
97
  end
@@ -28,15 +28,15 @@ module ROM
28
28
  def explain(format: :text, **options)
29
29
  bool_options = options.map { |opt, value| "#{opt.to_s.upcase} #{!!value}" }
30
30
  format_option = "FORMAT #{format.to_s.upcase}"
31
- explain_value = [format_option, *bool_options].join(', ')
31
+ explain_value = [format_option, *bool_options].join(", ")
32
32
 
33
33
  query = "EXPLAIN (#{explain_value}) #{dataset.sql}"
34
34
 
35
- rows = dataset.with_sql(query).map(:'QUERY PLAN')
35
+ rows = dataset.with_sql(query).map(:"QUERY PLAN")
36
36
 
37
37
  case format
38
38
  when :json
39
- rows[0][0]['Plan']
39
+ rows[0][0]["Plan"]
40
40
  else
41
41
  rows.join("\n")
42
42
  end
@@ -49,7 +49,7 @@ module ROM
49
49
  end
50
50
 
51
51
  ROM.plugins do
52
- adapter :sql do
52
+ adapter(:sql) do
53
53
  register :pg_explain, ROM::Plugins::Relation::SQL::Postgres::Explain, type: :relation
54
54
  end
55
55
  end
@@ -13,23 +13,24 @@ module ROM
13
13
  # By default, searching for the inclusion of any of the terms in any of the cols.
14
14
  #
15
15
  # @example
16
- # posts.full_text_search([:title, :content], 'apples', language: 'english') # => Relation which match the 'apples' phrase
17
- #
18
- # @option :headline [String] Append a expression to the selected columns aliased to headline that contains an extract of the matched text.
16
+ # # => Relation which match the 'apples' phrase
17
+ # posts.full_text_search([:title, :content], 'apples', language: 'english')
19
18
  #
19
+ # @option :headline [String] Append a expression to the selected columns aliased to headline that contains
20
+ # an extract of the matched text.
20
21
  # @option :language [String] The language to use for the search (default: 'simple')
21
- #
22
- # @option :plain [Boolean] Whether a plain search should be used (default: false). In this case, terms should be a single string, and it will do a search where cols contains all of the words in terms. This ignores search operators in terms.
23
- #
24
- # @option :phrase [Boolean] Similar to :plain, but also adding an ILIKE filter to ensure that returned rows also include the exact phrase used.
25
- #
22
+ # @option :plain [Boolean] Whether a plain search should be used (default: false). In this case, terms
23
+ # should be a single string, and it will do a search where cols contains all of the words in terms.
24
+ # This ignores search operators in terms.
25
+ # @option :phrase [Boolean] Similar to :plain, but also adding an ILIKE filter to ensure that returned rows
26
+ # also include the exact phrase used.
26
27
  # @option :rank [Boolean] Set to true to order by the rank, so that closer matches are returned first.
27
- #
28
- # @option :to_tsquery [Symbol] Can be set to :plain or :phrase to specify the function to use to convert the terms to a ts_query.
29
- #
30
- # @option :tsquery [Boolean] Specifies the terms argument is already a valid SQL expression returning a tsquery, and can be used directly in the query.
31
- #
32
- # @option :tsvector [Boolean] Specifies the cols argument is already a valid SQL expression returning a tsvector, and can be used directly in the query.
28
+ # @option :to_tsquery [Symbol] Can be set to :plain or :phrase to specify the function to use to convert
29
+ # the terms to a ts_query.
30
+ # @option :tsquery [Boolean] Specifies the terms argument is already a valid SQL expression returning
31
+ # a tsquery, and can be used directly in the query.
32
+ # @option :tsvector [Boolean] Specifies the cols argument is already a valid SQL expression returning
33
+ # a tsvector, and can be used directly in the query.
33
34
  #
34
35
  # @return [Relation]
35
36
  #
@@ -47,7 +48,8 @@ module ROM
47
48
  end
48
49
 
49
50
  ROM.plugins do
50
- adapter :sql do
51
- register :pg_full_text_search, ROM::Plugins::Relation::SQL::Postgres::FullTextSearch, type: :relation
51
+ adapter(:sql) do
52
+ register :pg_full_text_search, ROM::Plugins::Relation::SQL::Postgres::FullTextSearch,
53
+ type: :relation
52
54
  end
53
55
  end
@@ -9,16 +9,16 @@ module ROM
9
9
  #
10
10
  # @api public
11
11
  module Streaming
12
- extend Notifications::Listener
12
+ extend Dry::Effects.Reader(:registry)
13
13
 
14
14
  class StreamingNotSupportedError < StandardError; end
15
15
 
16
- subscribe("configuration.gateway.connected") do |opts|
17
- conn = opts[:connection]
16
+ def self.apply(target, **_opts)
17
+ conn = registry.gateways[target.config.component.gateway].connection
18
18
 
19
- next unless conn.database_type.to_sym == :postgres
19
+ return unless conn.database_type.to_sym == :postgres
20
20
 
21
- next if defined?(JRUBY_VERSION)
21
+ return if defined?(JRUBY_VERSION)
22
22
 
23
23
  begin
24
24
  require "sequel_pg"
@@ -31,8 +31,11 @@ module ROM
31
31
  end
32
32
 
33
33
  conn.extension(:pg_streaming)
34
+
35
+ target.include(Streaming)
34
36
  end
35
37
 
38
+ # @api private
36
39
  def self.included(klass)
37
40
  super
38
41
  ROM::Relation::Graph.include(Combined)
@@ -46,11 +49,11 @@ module ROM
46
49
  # @see https://github.com/jeremyevans/sequel_pg#streaming- sequel_pg docs
47
50
  #
48
51
  # @example
49
- # posts.steam_each { |post| puts CSV.generate_line(post) }
52
+ # posts.stream_each { |post| puts CSV.generate_line(post) }
50
53
  #
51
54
  # @return [Relation]
52
55
  #
53
- # @api publicY_VERSION
56
+ # @api public
54
57
  def stream_each
55
58
  raise StreamingNotSupportedError, "not supported on jruby"
56
59
  end
@@ -61,7 +64,7 @@ module ROM
61
64
  # @see https://github.com/jeremyevans/sequel_pg#streaming- sequel_pg docs
62
65
  #
63
66
  # @example
64
- # posts.steam_each { |post| puts CSV.generate_line(post) }
67
+ # posts.stream_each { |post| puts CSV.generate_line(post) }
65
68
  #
66
69
  # @return [Relation]
67
70
  #
@@ -102,7 +105,7 @@ module ROM
102
105
  end
103
106
 
104
107
  ROM.plugins do
105
- adapter :sql do
108
+ adapter(:sql) do
106
109
  register :pg_streaming, ROM::Plugins::Relation::SQL::Postgres::Streaming, type: :relation
107
110
  end
108
111
  end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rom/associations/many_to_many'
4
- require 'rom/sql/associations/core'
5
- require 'rom/sql/associations/self_ref'
3
+ require "rom/associations/many_to_many"
4
+ require "rom/sql/associations/core"
5
+ require "rom/sql/associations/self_ref"
6
6
 
7
7
  module ROM
8
8
  module SQL
@@ -17,10 +17,10 @@ module ROM
17
17
 
18
18
  schema =
19
19
  if left.schema.key?(foreign_key)
20
- if target != self.target
21
- target.schema.merge(join_schema)
22
- else
20
+ if target == self.target
23
21
  left.schema.uniq.project(*columns)
22
+ else
23
+ target.schema.merge(join_schema)
24
24
  end
25
25
  else
26
26
  target_schema
@@ -50,7 +50,7 @@ module ROM
50
50
 
51
51
  # @api public
52
52
  def join_keys
53
- { source_attr => target_attr }
53
+ {source_attr => target_attr}
54
54
  end
55
55
 
56
56
  # @api public
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rom/associations/many_to_one'
4
- require 'rom/sql/associations/core'
5
- require 'rom/sql/associations/self_ref'
3
+ require "rom/associations/many_to_one"
4
+ require "rom/sql/associations/core"
5
+ require "rom/sql/associations/self_ref"
6
6
 
7
7
  module ROM
8
8
  module SQL
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rom/associations/one_to_many'
4
- require 'rom/sql/associations/core'
5
- require 'rom/sql/associations/self_ref'
3
+ require "rom/associations/one_to_many"
4
+ require "rom/sql/associations/core"
5
+ require "rom/sql/associations/self_ref"
6
6
 
7
7
  module ROM
8
8
  module SQL
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rom/sql/associations/one_to_many'
3
+ require "rom/sql/associations/one_to_many"
4
4
 
5
5
  module ROM
6
6
  module SQL
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rom/sql/associations/many_to_many'
3
+ require "rom/sql/associations/many_to_many"
4
4
 
5
5
  module ROM
6
6
  module SQL
@@ -11,7 +11,7 @@ module ROM
11
11
 
12
12
  # @api public
13
13
  def join_keys
14
- { source_attr => target_attr }
14
+ {source_attr => target_attr}
15
15
  end
16
16
 
17
17
  # @api public
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rom/sql/associations/many_to_many'
4
- require 'rom/sql/associations/many_to_one'
5
- require 'rom/sql/associations/one_to_many'
6
- require 'rom/sql/associations/one_to_one'
7
- require 'rom/sql/associations/one_to_one_through'
3
+ require "rom/sql/associations/many_to_many"
4
+ require "rom/sql/associations/many_to_one"
5
+ require "rom/sql/associations/one_to_many"
6
+ require "rom/sql/associations/one_to_one"
7
+ require "rom/sql/associations/one_to_one_through"
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'sequel/core'
4
- require 'dry/core/cache'
3
+ require "sequel/core"
4
+ require "dry/core/cache"
5
5
 
6
- require 'rom/attribute'
6
+ require "rom/attribute"
7
7
 
8
- require 'rom/sql/type_extensions'
9
- require 'rom/sql/projection_dsl'
10
- require 'rom/sql/attribute_wrapping'
11
- require 'rom/sql/attribute_aliasing'
8
+ require "rom/sql/type_extensions"
9
+ require "rom/sql/projection_dsl"
10
+ require "rom/sql/attribute_wrapping"
11
+ require "rom/sql/attribute_aliasing"
12
12
 
13
13
  module ROM
14
14
  module SQL
@@ -280,7 +280,7 @@ module ROM
280
280
  # @return [SQL::Function]
281
281
  #
282
282
  # @api public
283
- def concat(other, sep = ' ')
283
+ def concat(other, sep = " ")
284
284
  Function.new(type).concat(self, sep, other)
285
285
  end
286
286
 
@@ -366,7 +366,7 @@ module ROM
366
366
  def case(mapping)
367
367
  mapping = mapping.dup
368
368
  otherwise = mapping.delete(:else) do
369
- raise ArgumentError, 'provide the default case using the :else keyword'
369
+ raise ArgumentError, "provide the default case using the :else keyword"
370
370
  end
371
371
 
372
372
  type = mapping.values[0].type
@@ -19,8 +19,7 @@ module ROM
19
19
  sql_expr: alias_sql_expr(sql_expr, new_alias_name)
20
20
  )
21
21
  end
22
- alias as aliased
23
-
22
+ alias_method :as, :aliased
24
23
 
25
24
  # Return true if this attribute is an aliased projection
26
25
  #
@@ -46,7 +45,7 @@ module ROM
46
45
  #
47
46
  # @api private
48
47
  def aliased_projection?
49
- self.meta[:sql_expr].is_a?(Sequel::SQL::AliasedExpression)
48
+ meta[:sql_expr].is_a?(Sequel::SQL::AliasedExpression)
50
49
  end
51
50
 
52
51
  private
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rom/sql/commands/error_wrapper'
3
+ require "rom/sql/commands/error_wrapper"
4
4
 
5
5
  module ROM
6
6
  module SQL
@@ -9,7 +9,7 @@ module ROM
9
9
  #
10
10
  # @api public
11
11
  class Create < ROM::Commands::Create
12
- adapter :sql
12
+ config.component.adapter = :sql
13
13
 
14
14
  include ErrorWrapper
15
15
 
@@ -60,10 +60,11 @@ module ROM
60
60
  # Yields tuples for insertion or return an enumerator
61
61
  #
62
62
  # @api private
63
- def with_input_tuples(tuples)
63
+ def with_input_tuples(tuples, &block)
64
64
  input_tuples = Array([tuples]).flatten(1).map
65
65
  return input_tuples unless block_given?
66
- input_tuples.each { |tuple| yield(tuple) }
66
+
67
+ input_tuples.each(&block)
67
68
  end
68
69
  end
69
70
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rom/sql/commands/error_wrapper'
3
+ require "rom/sql/commands/error_wrapper"
4
4
 
5
5
  module ROM
6
6
  module SQL
@@ -9,7 +9,7 @@ module ROM
9
9
  #
10
10
  # @api public
11
11
  class Delete < ROM::Commands::Delete
12
- adapter :sql
12
+ config.component.adapter = :sql
13
13
 
14
14
  include ErrorWrapper
15
15