torque-postgresql 1.1.7 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/lib/torque/postgresql.rb +0 -2
  3. data/lib/torque/postgresql/adapter.rb +7 -1
  4. data/lib/torque/postgresql/adapter/database_statements.rb +6 -15
  5. data/lib/torque/postgresql/adapter/oid.rb +3 -1
  6. data/lib/torque/postgresql/adapter/oid/box.rb +2 -0
  7. data/lib/torque/postgresql/adapter/oid/circle.rb +2 -0
  8. data/lib/torque/postgresql/adapter/oid/enum.rb +2 -0
  9. data/lib/torque/postgresql/adapter/oid/enum_set.rb +2 -0
  10. data/lib/torque/postgresql/adapter/oid/interval.rb +2 -0
  11. data/lib/torque/postgresql/adapter/oid/line.rb +2 -0
  12. data/lib/torque/postgresql/adapter/oid/range.rb +2 -0
  13. data/lib/torque/postgresql/adapter/oid/segment.rb +2 -0
  14. data/lib/torque/postgresql/adapter/quoting.rb +2 -0
  15. data/lib/torque/postgresql/adapter/schema_creation.rb +20 -23
  16. data/lib/torque/postgresql/adapter/schema_definitions.rb +9 -21
  17. data/lib/torque/postgresql/adapter/schema_dumper.rb +76 -11
  18. data/lib/torque/postgresql/adapter/schema_statements.rb +4 -12
  19. data/lib/torque/postgresql/arel/infix_operation.rb +5 -1
  20. data/lib/torque/postgresql/arel/join_source.rb +2 -0
  21. data/lib/torque/postgresql/arel/nodes.rb +2 -0
  22. data/lib/torque/postgresql/arel/operations.rb +2 -0
  23. data/lib/torque/postgresql/arel/select_manager.rb +2 -0
  24. data/lib/torque/postgresql/arel/visitors.rb +6 -3
  25. data/lib/torque/postgresql/associations.rb +0 -3
  26. data/lib/torque/postgresql/associations/association.rb +5 -1
  27. data/lib/torque/postgresql/associations/association_scope.rb +20 -60
  28. data/lib/torque/postgresql/associations/belongs_to_many_association.rb +5 -1
  29. data/lib/torque/postgresql/associations/builder/belongs_to_many.rb +2 -0
  30. data/lib/torque/postgresql/associations/builder/has_many.rb +2 -0
  31. data/lib/torque/postgresql/associations/preloader.rb +0 -32
  32. data/lib/torque/postgresql/associations/preloader/association.rb +42 -10
  33. data/lib/torque/postgresql/attributes/builder.rb +2 -0
  34. data/lib/torque/postgresql/attributes/builder/enum.rb +5 -3
  35. data/lib/torque/postgresql/attributes/builder/period.rb +6 -4
  36. data/lib/torque/postgresql/attributes/enum.rb +5 -10
  37. data/lib/torque/postgresql/attributes/enum_set.rb +2 -0
  38. data/lib/torque/postgresql/attributes/lazy.rb +3 -1
  39. data/lib/torque/postgresql/attributes/period.rb +2 -0
  40. data/lib/torque/postgresql/autosave_association.rb +9 -3
  41. data/lib/torque/postgresql/auxiliary_statement.rb +3 -13
  42. data/lib/torque/postgresql/auxiliary_statement/settings.rb +2 -0
  43. data/lib/torque/postgresql/base.rb +2 -0
  44. data/lib/torque/postgresql/coder.rb +6 -5
  45. data/lib/torque/postgresql/collector.rb +2 -0
  46. data/lib/torque/postgresql/config.rb +3 -4
  47. data/lib/torque/postgresql/geometry_builder.rb +2 -0
  48. data/lib/torque/postgresql/i18n.rb +2 -0
  49. data/lib/torque/postgresql/inheritance.rb +15 -17
  50. data/lib/torque/postgresql/migration/command_recorder.rb +2 -0
  51. data/lib/torque/postgresql/railtie.rb +2 -0
  52. data/lib/torque/postgresql/reflection.rb +2 -0
  53. data/lib/torque/postgresql/reflection/abstract_reflection.rb +28 -26
  54. data/lib/torque/postgresql/reflection/association_reflection.rb +2 -0
  55. data/lib/torque/postgresql/reflection/belongs_to_many_reflection.rb +6 -26
  56. data/lib/torque/postgresql/reflection/has_many_reflection.rb +2 -0
  57. data/lib/torque/postgresql/reflection/runtime_reflection.rb +2 -0
  58. data/lib/torque/postgresql/reflection/through_reflection.rb +2 -0
  59. data/lib/torque/postgresql/relation.rb +10 -11
  60. data/lib/torque/postgresql/relation/auxiliary_statement.rb +7 -8
  61. data/lib/torque/postgresql/relation/distinct_on.rb +3 -1
  62. data/lib/torque/postgresql/relation/inheritance.rb +2 -0
  63. data/lib/torque/postgresql/relation/merger.rb +2 -0
  64. data/lib/torque/postgresql/schema_cache.rb +2 -0
  65. data/lib/torque/postgresql/version.rb +3 -1
  66. data/spec/en.yml +19 -0
  67. data/spec/factories/authors.rb +6 -0
  68. data/spec/factories/comments.rb +13 -0
  69. data/spec/factories/posts.rb +6 -0
  70. data/spec/factories/tags.rb +5 -0
  71. data/spec/factories/texts.rb +5 -0
  72. data/spec/factories/users.rb +6 -0
  73. data/spec/factories/videos.rb +5 -0
  74. data/spec/mocks/cache_query.rb +16 -0
  75. data/spec/mocks/create_table.rb +35 -0
  76. data/spec/models/activity.rb +3 -0
  77. data/spec/models/activity_book.rb +4 -0
  78. data/spec/models/activity_post.rb +7 -0
  79. data/spec/models/activity_post/sample.rb +4 -0
  80. data/spec/models/author.rb +4 -0
  81. data/spec/models/author_journalist.rb +4 -0
  82. data/spec/models/comment.rb +3 -0
  83. data/spec/models/course.rb +2 -0
  84. data/spec/models/geometry.rb +2 -0
  85. data/spec/models/guest_comment.rb +4 -0
  86. data/spec/models/post.rb +6 -0
  87. data/spec/models/tag.rb +2 -0
  88. data/spec/models/text.rb +2 -0
  89. data/spec/models/time_keeper.rb +2 -0
  90. data/spec/models/user.rb +8 -0
  91. data/spec/models/video.rb +2 -0
  92. data/spec/schema.rb +141 -0
  93. data/spec/spec_helper.rb +59 -0
  94. data/spec/tests/arel_spec.rb +74 -0
  95. data/spec/tests/auxiliary_statement_spec.rb +593 -0
  96. data/spec/tests/belongs_to_many_spec.rb +246 -0
  97. data/spec/tests/coder_spec.rb +367 -0
  98. data/spec/tests/collector_spec.rb +59 -0
  99. data/spec/tests/distinct_on_spec.rb +65 -0
  100. data/spec/tests/enum_set_spec.rb +306 -0
  101. data/spec/tests/enum_spec.rb +628 -0
  102. data/spec/tests/geometric_builder_spec.rb +221 -0
  103. data/spec/tests/has_many_spec.rb +400 -0
  104. data/spec/tests/interval_spec.rb +167 -0
  105. data/spec/tests/lazy_spec.rb +24 -0
  106. data/spec/tests/period_spec.rb +954 -0
  107. data/spec/tests/quoting_spec.rb +24 -0
  108. data/spec/tests/range_spec.rb +36 -0
  109. data/spec/tests/relation_spec.rb +57 -0
  110. data/spec/tests/table_inheritance_spec.rb +416 -0
  111. metadata +102 -14
  112. data/lib/torque/postgresql/associations/join_dependency/join_association.rb +0 -15
  113. data/lib/torque/postgresql/schema_dumper.rb +0 -91
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ac2d4e3c96cf93edeac515986a6b7ba3ca412712c6eb19a38f09e0b0e5e448a
4
- data.tar.gz: 133b756202e8e39738d7bda361f3fd9544829ef817b7ac518f972bf175da93c1
3
+ metadata.gz: f108bfb672743d7edd701b77eb102aa6f9164b4981e1f366d2354d9e8cf3360b
4
+ data.tar.gz: 60d7208f0798acbde69aee78fca7a92d4824c75dcecc44acd16dcf59568f0e04
5
5
  SHA512:
6
- metadata.gz: '08a2cb8062f7bdcf6497f4c2b33dc102c6df5d45ed5c82f6c772caeddb02f7a87056b06b13e6c09359b9db52dff46eabcb64f644e17682b1f830fdd988ff44ea'
7
- data.tar.gz: f419dd80f7a3c9972b0eb469ed63bf5454ede498ee688761f7c99587db8b2d48d06b5b40e4696a1760ea077f750d966a9e67a500b5b2d4b8b0fa3fccc1c0f884
6
+ metadata.gz: 0a463f94c5a09f74bbb2ba57fe9fb2f7fe649f243c239f7709180c29988f2b5424bffec68d0ec1d2c4ae8ad1191d6156e96dd00c2a66a2a473e02411c563e21f
7
+ data.tar.gz: 1568915cd13e2b93b77a702cfd346326aa9e07605aac3deca0f3dacbe82b24762a84f3007a4dffc493888c94802724defbfc01037d0bad984e3735783a790f35
@@ -6,7 +6,6 @@ require 'active_support'
6
6
 
7
7
  require 'active_support/core_ext/date/acts_like'
8
8
  require 'active_support/core_ext/time/zones'
9
- require 'active_support/core_ext/hash/compact'
10
9
  require 'active_record/connection_adapters/postgresql_adapter'
11
10
 
12
11
  require 'torque/postgresql/config'
@@ -28,6 +27,5 @@ require 'torque/postgresql/migration'
28
27
  require 'torque/postgresql/relation'
29
28
  require 'torque/postgresql/reflection'
30
29
  require 'torque/postgresql/schema_cache'
31
- require 'torque/postgresql/schema_dumper'
32
30
 
33
31
  require 'torque/postgresql/railtie' if defined?(Rails)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'adapter/database_statements'
2
4
  require_relative 'adapter/oid'
3
5
  require_relative 'adapter/quoting'
@@ -10,7 +12,6 @@ module Torque
10
12
  module PostgreSQL
11
13
  module Adapter
12
14
  include Quoting
13
- include ColumnDumper unless Torque::PostgreSQL::AR521
14
15
  include DatabaseStatements
15
16
  include SchemaStatements
16
17
 
@@ -20,6 +21,11 @@ module Torque
20
21
  select_value('SELECT version()').match(/#{Adapter::ADAPTER_NAME} ([\d\.]+)/)[1]
21
22
  )
22
23
  end
24
+
25
+ # Add `inherits` to the list of extracted table options
26
+ def extract_table_options!(options)
27
+ super.merge(options.extract!(:inherits))
28
+ end
23
29
  end
24
30
 
25
31
  ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.prepend Adapter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Torque
2
4
  module PostgreSQL
3
5
  module Adapter
@@ -43,16 +45,9 @@ module Torque
43
45
  end
44
46
 
45
47
  # :nodoc:
46
- if Torque::PostgreSQL::AR521
47
- def load_additional_types(oids = nil)
48
- super
49
- torque_load_additional_types(oids)
50
- end
51
- else
52
- def load_additional_types(type_map, oids = nil)
53
- super
54
- torque_load_additional_types(oids)
55
- end
48
+ def load_additional_types(oids = nil)
49
+ super
50
+ torque_load_additional_types(oids)
56
51
  end
57
52
 
58
53
  # Add the composite types to be loaded too.
@@ -80,11 +75,7 @@ module Torque
80
75
  SQL
81
76
 
82
77
  execute_and_clear(query, 'SCHEMA', []) do |records|
83
- records.each do |row|
84
- case row['typtype']
85
- when 'e' then OID::Enum.create(row, type_map)
86
- end
87
- end
78
+ records.each { |row| OID::Enum.create(row, type_map) }
88
79
  end
89
80
  end
90
81
 
@@ -17,9 +17,11 @@ module Torque
17
17
  ActiveRecord::Type.register(:circle, OID::Circle, adapter: :postgresql)
18
18
  ActiveRecord::Type.register(:enum, OID::Enum, adapter: :postgresql)
19
19
  ActiveRecord::Type.register(:enum_set, OID::EnumSet, adapter: :postgresql)
20
- ActiveRecord::Type.register(:interval, OID::Interval, adapter: :postgresql)
21
20
  ActiveRecord::Type.register(:line, OID::Line, adapter: :postgresql)
22
21
  ActiveRecord::Type.register(:segment, OID::Segment, adapter: :postgresql)
22
+
23
+ ActiveRecord::Type.register(:interval, OID::Interval, adapter: :postgresql) \
24
+ unless PostgreSQL::AR610
23
25
  end
24
26
  end
25
27
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Torque
2
4
  module PostgreSQL
3
5
  class Box < Struct.new(:x1, :y1, :x2, :y2)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Torque
2
4
  module PostgreSQL
3
5
  class Circle < Struct.new(:x, :y, :r)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Torque
2
4
  module PostgreSQL
3
5
  module Adapter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Torque
2
4
  module PostgreSQL
3
5
  module Adapter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Torque
2
4
  module PostgreSQL
3
5
  module Adapter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Torque
2
4
  module PostgreSQL
3
5
  class Line < Struct.new(:slope, :intercept)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Torque
2
4
  module PostgreSQL
3
5
  module Adapter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Torque
2
4
  module PostgreSQL
3
5
  class Segment < Struct.new(:point0, :point1)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Torque
2
4
  module PostgreSQL
3
5
  module Adapter
@@ -5,10 +5,11 @@ module Torque
5
5
 
6
6
  # Redefine original table creation command to ensure PostgreSQL standard
7
7
  def visit_TableDefinition(o)
8
- create_sql = "CREATE#{' TEMPORARY' if o.temporary}"
9
- create_sql << " TABLE #{quote_table_name(o.name)}"
8
+ create_sql = +"CREATE#{table_modifier_in_create(o)} TABLE "
9
+ create_sql << "IF NOT EXISTS " if o.if_not_exists
10
+ create_sql << "#{quote_table_name(o.name)} "
10
11
 
11
- statements = o.columns.map{ |c| accept c }
12
+ statements = o.columns.map { |c| accept c }
12
13
  statements << accept(o.primary_keys) if o.primary_keys
13
14
 
14
15
  if supports_indexes_in_create?
@@ -17,36 +18,32 @@ module Torque
17
18
  end)
18
19
  end
19
20
 
20
- if supports_foreign_keys_in_create?
21
+ if supports_foreign_keys?
21
22
  statements.concat(o.foreign_keys.map do |to_table, options|
22
23
  foreign_key_in_create(o.name, to_table, options)
23
24
  end)
24
25
  end
25
26
 
26
- if o.as
27
- create_sql << " AS #{@conn.to_sql(o.as)}"
28
- else
29
- create_sql << " (#{statements.join(', ')})"
30
- add_table_options!(create_sql, table_options(o))
31
-
32
- if o.inherits.present?
33
- tables = o.inherits.map(&method(:quote_table_name))
34
- create_sql << " INHERITS ( #{tables.join(' , ')} )"
35
- end
27
+ if respond_to?(:supports_check_constraints?) && supports_check_constraints?
28
+ statements.concat(o.check_constraints.map do |expression, options|
29
+ check_constraint_in_create(o.name, expression, options)
30
+ end)
36
31
  end
37
32
 
38
- create_sql
39
- end
33
+ create_sql << "(#{statements.join(', ')})" \
34
+ if statements.present? || o.inherits.present?
40
35
 
41
- # Keep rails 5.0 and 5.1 compatibility
42
- def supports_foreign_keys_in_create?
43
- if defined?(super)
44
- super
45
- else
46
- supports_foreign_keys?
36
+ options = PostgreSQL::AR610 ? o : table_options(o)
37
+ add_table_options!(create_sql, options)
38
+
39
+ if o.inherits.present?
40
+ tables = o.inherits.map(&method(:quote_table_name))
41
+ create_sql << " INHERITS ( #{tables.join(' , ')} )"
47
42
  end
48
- end
49
43
 
44
+ create_sql << " AS #{to_sql(o.as)}" if o.as
45
+ create_sql
46
+ end
50
47
  end
51
48
 
52
49
  ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaCreation.prepend SchemaCreation
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Torque
2
4
  module PostgreSQL
3
5
  module Adapter
@@ -7,17 +9,15 @@ module Torque
7
9
  # dates to be stored without having to store a seconds-based integer
8
10
  # or any sort of other approach
9
11
  def interval(*args, **options)
10
- args.each { |name| column(name, :interval, options) }
12
+ args.each { |name| column(name, :interval, **options) }
11
13
  end
12
14
 
13
15
  # Creates a column with an enum type, needing to specify the subtype,
14
16
  # which is basically the name of the type defined prior creating the
15
17
  # column
16
18
  def enum(*args, **options)
17
- args.each do |name|
18
- type = options.fetch(:subtype, name)
19
- column(name, type, options)
20
- end
19
+ subtype = options.delete(:subtype)
20
+ args.each { |name| column(name, (subtype || name), **options) }
21
21
  end
22
22
 
23
23
  # Creates a column with an enum array type, needing to specify the
@@ -34,23 +34,11 @@ module Torque
34
34
 
35
35
  attr_reader :inherits
36
36
 
37
- def initialize(name, *_, **options)
38
- old_args = []
39
- old_args << options.delete(:temporary) || false
40
- old_args << options.delete(:options)
41
- old_args << options.delete(:as)
42
- comment = options.delete(:comment)
43
-
44
- super(name, *old_args, comment: comment)
45
-
46
- if options.key?(:inherits)
47
- @inherits = Array[options.delete(:inherits)].flatten.compact
48
- @inherited_id = !(options.key?(:primary_key) || options.key?(:id))
49
- end
50
- end
37
+ def initialize(*args, **options)
38
+ super
51
39
 
52
- def inherited_id?
53
- @inherited_id
40
+ @inherits = Array.wrap(options.delete(:inherits)).flatten.compact \
41
+ if options.key?(:inherits)
54
42
  end
55
43
  end
56
44
 
@@ -1,22 +1,25 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Torque
2
4
  module PostgreSQL
3
5
  module Adapter
4
- module ColumnDumper
6
+ module SchemaDumper
7
+ def dump(stream) # :nodoc:
8
+ @connection.dump_mode!
9
+ super
5
10
 
6
- # Adds +:subtype+ as a valid migration key
7
- unless Torque::PostgreSQL::AR521
8
- def migration_keys
9
- super + [:subtype]
10
- end
11
+ @connection.dump_mode!
12
+ stream
13
+ end
14
+
15
+ def extensions(stream) # :nodoc:
16
+ super
17
+ user_defined_types(stream)
11
18
  end
12
19
 
13
20
  # Translate +:enum_set+ into +:enum+
14
21
  def schema_type(column)
15
- if column.type == :enum_set
16
- :enum
17
- else
18
- super
19
- end
22
+ column.type == :enum_set ? :enum : super
20
23
  end
21
24
 
22
25
  # Adds +:subtype+ option to the default set
@@ -36,7 +39,69 @@ module Torque
36
39
  column.sql_type.to_sym.inspect if column.type == :enum || column.type == :enum_set
37
40
  end
38
41
 
42
+ def tables(stream) # :nodoc:
43
+ inherited_tables = @connection.inherited_tables
44
+ sorted_tables = @connection.tables.sort - @connection.views
45
+
46
+ stream.puts " # These are the common tables managed"
47
+ (sorted_tables - inherited_tables.keys).each do |table_name|
48
+ table(table_name, stream) unless ignored?(table_name)
49
+ end
50
+
51
+ if inherited_tables.present?
52
+ stream.puts " # These are tables that has inheritance"
53
+ inherited_tables.each do |table_name, inherits|
54
+ next if ignored?(table_name)
55
+
56
+ sub_stream = StringIO.new
57
+ table(table_name, sub_stream)
58
+
59
+ # Add the inherits setting
60
+ sub_stream.rewind
61
+ inherits.map!(&:to_sym)
62
+ inherits = inherits.first if inherits.size === 1
63
+ inherits = ", inherits: #{inherits.inspect} do |t|"
64
+ table_dump = sub_stream.read.gsub(/ do \|t\|$/, inherits)
65
+
66
+ # Ensure bodyless definitions
67
+ table_dump.gsub!(/do \|t\|\n end/, '')
68
+ stream.print table_dump
69
+ end
70
+ end
71
+
72
+ # Dump foreign keys at the end to make sure all dependent tables exist.
73
+ if @connection.supports_foreign_keys?
74
+ sorted_tables.each do |tbl|
75
+ foreign_keys(tbl, stream) unless ignored?(tbl)
76
+ end
77
+ end
78
+
79
+ # Scenic integration
80
+ views(stream) if defined?(::Scenic)
81
+ end
82
+
83
+ # Dump user defined types like enum
84
+ def user_defined_types(stream)
85
+ types = @connection.user_defined_types('e')
86
+ return unless types.any?
87
+
88
+ stream.puts " # These are user-defined types used on this database"
89
+ types.sort_by(&:first).each { |(name, type)| send(type.to_sym, name, stream) }
90
+ stream.puts
91
+ rescue => e
92
+ stream.puts "# Could not dump user-defined types because of following #{e.class}"
93
+ stream.puts "# #{e.message}"
94
+ stream.puts
95
+ end
96
+
97
+ # Dump enum custom type
98
+ def enum(name, stream)
99
+ values = @connection.enum_values(name).map { |v| "\"#{v}\"" }
100
+ stream.puts " create_enum \"#{name}\", [#{values.join(', ')}], force: :cascade"
101
+ end
39
102
  end
103
+
104
+ ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaDumper.prepend SchemaDumper
40
105
  end
41
106
  end
42
107
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Torque
2
4
  module PostgreSQL
3
5
  module Adapter
@@ -73,24 +75,14 @@ module Torque
73
75
 
74
76
  # Rewrite the method that creates tables to easily accept extra options
75
77
  def create_table(table_name, **options, &block)
76
- td = create_table_definition(table_name, **options)
77
- options[:id] = false if td.inherited_id?
78
- options[:temporary] = td
78
+ options[:id] = false if options[:inherits].present? &&
79
+ options[:primary_key].blank? && options[:id].blank?
79
80
 
80
81
  super table_name, **options, &block
81
82
  end
82
83
 
83
84
  private
84
85
 
85
- # This waits for the second call to really return the table definition
86
- def create_table_definition(*args, **options) # :nodoc:
87
- if !args.second.kind_of?(TableDefinition)
88
- TableDefinition.new(*args, **options)
89
- else
90
- args.second
91
- end
92
- end
93
-
94
86
  def quote_enum_values(name, values, options)
95
87
  prefix = options[:prefix]
96
88
  prefix = name if prefix === true
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Torque
2
4
  module PostgreSQL
3
5
  module Arel
@@ -22,6 +24,8 @@ module Torque
22
24
  }.freeze
23
25
 
24
26
  INFLIX_OPERATION.each do |operator_name, operator|
27
+ next if nodes.const_defined?(operator_name)
28
+
25
29
  klass = Class.new(inflix)
26
30
  klass.send(:define_method, :initialize) { |*args| super(operator, *args) }
27
31
 
@@ -31,7 +35,7 @@ module Torque
31
35
  # Don't worry about quoting here, if the right side is something that
32
36
  # doesn't need quoting, it will leave it as it is
33
37
  Math.send(:define_method, operator_name.underscore) do |other|
34
- klass.new(self, nodes.build_quoted(other, self))
38
+ klass.new(self, other)
35
39
  end
36
40
  end
37
41