activerecord7-redshift-adapter-pennylane 1.0.3 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/lib/active_record/connection_adapters/redshift_7_0/oid/decimal.rb +1 -1
  3. data/lib/active_record/connection_adapters/redshift_7_0/schema_statements.rb +3 -3
  4. data/lib/active_record/connection_adapters/redshift_7_0_adapter.rb +0 -2
  5. data/lib/active_record/connection_adapters/redshift_7_1/oid/decimal.rb +1 -1
  6. data/lib/active_record/connection_adapters/redshift_7_1/quoting.rb +1 -1
  7. data/lib/active_record/connection_adapters/redshift_7_1/schema_statements.rb +3 -3
  8. data/lib/active_record/connection_adapters/redshift_7_1_adapter.rb +0 -1
  9. data/lib/active_record/connection_adapters/redshift_7_2/array_parser.rb +92 -0
  10. data/lib/active_record/connection_adapters/redshift_7_2/column.rb +17 -0
  11. data/lib/active_record/connection_adapters/redshift_7_2/database_statements.rb +180 -0
  12. data/lib/active_record/connection_adapters/redshift_7_2/oid/date_time.rb +36 -0
  13. data/lib/active_record/connection_adapters/redshift_7_2/oid/decimal.rb +15 -0
  14. data/lib/active_record/connection_adapters/redshift_7_2/oid/json.rb +41 -0
  15. data/lib/active_record/connection_adapters/redshift_7_2/oid/jsonb.rb +25 -0
  16. data/lib/active_record/connection_adapters/redshift_7_2/oid/type_map_initializer.rb +62 -0
  17. data/lib/active_record/connection_adapters/redshift_7_2/oid.rb +17 -0
  18. data/lib/active_record/connection_adapters/redshift_7_2/quoting.rb +164 -0
  19. data/lib/active_record/connection_adapters/redshift_7_2/referential_integrity.rb +17 -0
  20. data/lib/active_record/connection_adapters/redshift_7_2/schema_definitions.rb +70 -0
  21. data/lib/active_record/connection_adapters/redshift_7_2/schema_dumper.rb +17 -0
  22. data/lib/active_record/connection_adapters/redshift_7_2/schema_statements.rb +422 -0
  23. data/lib/active_record/connection_adapters/redshift_7_2/type_metadata.rb +43 -0
  24. data/lib/active_record/connection_adapters/redshift_7_2/utils.rb +81 -0
  25. data/lib/active_record/connection_adapters/redshift_7_2_adapter.rb +847 -0
  26. data/lib/active_record/connection_adapters/redshift_adapter.rb +8 -2
  27. data/lib/active_record/tasks/redshift_7_0_tasks.rb +148 -0
  28. data/lib/active_record/tasks/redshift_7_1_tasks.rb +151 -0
  29. data/lib/active_record/tasks/redshift_7_2_tasks.rb +151 -0
  30. data/lib/active_record/tasks/redshift_tasks.rb +11 -0
  31. data/lib/activerecord7-redshift-adapter-pennylane.rb +13 -0
  32. metadata +25 -3
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRecord
4
+ module ConnectionAdapters
5
+ module Redshift
6
+ class TypeMetadata < DelegateClass(SqlTypeMetadata)
7
+ undef to_yaml if method_defined?(:to_yaml)
8
+
9
+ include Deduplicable
10
+
11
+ attr_reader :oid, :fmod
12
+
13
+ def initialize(type_metadata, oid: nil, fmod: nil)
14
+ super(type_metadata)
15
+ @oid = oid
16
+ @fmod = fmod
17
+ end
18
+
19
+ def ==(other)
20
+ other.is_a?(TypeMetadata) &&
21
+ __getobj__ == other.__getobj__ &&
22
+ oid == other.oid &&
23
+ fmod == other.fmod
24
+ end
25
+ alias eql? ==
26
+
27
+ def hash
28
+ TypeMetadata.hash ^
29
+ __getobj__.hash ^
30
+ oid.hash ^
31
+ fmod.hash
32
+ end
33
+
34
+ private
35
+ def deduplicated
36
+ __setobj__(__getobj__.deduplicate)
37
+ super
38
+ end
39
+ end
40
+ end
41
+ RedshiftTypeMetadata = Redshift::TypeMetadata
42
+ end
43
+ end
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRecord
4
+ module ConnectionAdapters
5
+ module Redshift
6
+ # Value Object to hold a schema qualified name.
7
+ # This is usually the name of a PostgreSQL relation but it can also represent
8
+ # schema qualified type names. +schema+ and +identifier+ are unquoted to prevent
9
+ # double quoting.
10
+ class Name # :nodoc:
11
+ SEPARATOR = '.'
12
+ attr_reader :schema, :identifier
13
+
14
+ def initialize(schema, identifier)
15
+ @schema = unquote(schema)
16
+ @identifier = unquote(identifier)
17
+ end
18
+
19
+ def to_s
20
+ parts.join SEPARATOR
21
+ end
22
+
23
+ def quoted
24
+ if schema
25
+ PG::Connection.quote_ident(schema) << SEPARATOR << PG::Connection.quote_ident(identifier)
26
+ else
27
+ PG::Connection.quote_ident(identifier)
28
+ end
29
+ end
30
+
31
+ def ==(other)
32
+ other.class == self.class && other.parts == parts
33
+ end
34
+ alias eql? ==
35
+
36
+ def hash
37
+ parts.hash
38
+ end
39
+
40
+ protected
41
+
42
+ def unquote(part)
43
+ if part&.start_with?('"')
44
+ part[1..-2]
45
+ else
46
+ part
47
+ end
48
+ end
49
+
50
+ def parts
51
+ @parts ||= [@schema, @identifier].compact
52
+ end
53
+ end
54
+
55
+ module Utils # :nodoc:
56
+ module_function
57
+
58
+ # Returns an instance of <tt>ActiveRecord::ConnectionAdapters::PostgreSQL::Name</tt>
59
+ # extracted from +string+.
60
+ # +schema+ is nil if not specified in +string+.
61
+ # +schema+ and +identifier+ exclude surrounding quotes (regardless of whether provided in +string+)
62
+ # +string+ supports the range of schema/table references understood by PostgreSQL, for example:
63
+ #
64
+ # * <tt>table_name</tt>
65
+ # * <tt>"table.name"</tt>
66
+ # * <tt>schema_name.table_name</tt>
67
+ # * <tt>schema_name."table.name"</tt>
68
+ # * <tt>"schema_name".table_name</tt>
69
+ # * <tt>"schema.name"."table name"</tt>
70
+ def extract_schema_qualified_name(string)
71
+ schema, table = string.scan(/[^".\s]+|"[^"]*"/)
72
+ if table.nil?
73
+ table = schema
74
+ schema = nil
75
+ end
76
+ Redshift::Name.new(schema, table)
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end