pg_saurus 4.0.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b32de47fc9d97bfc956d5e2e26c9601ed2da3866dea9a51b97722c90d4b1db7
4
- data.tar.gz: 497db5f622d6332efa57216e13527b71a2895125856330e320166f342e088637
3
+ metadata.gz: d4621e5c56482cf923810bd206b2449469102f56a92a55acf002d004c5664675
4
+ data.tar.gz: 8c5b2e568586c128e7d0a248ef6cdd2b8c1f67e8e02e888fa4f2eee5bcd8adde
5
5
  SHA512:
6
- metadata.gz: 4626a2eeaf870f6a000e048e0d7264aaf8d79486c09eaffd247358f14d83eb2cfe201f758d62b60bfb5a6da4ce5dddbdbc1ce701350920bf88c5f4396a4bb196
7
- data.tar.gz: e5c098daabeaa492376e42dfbd1639439d09c9f457323e43f4f00c240d8d4a5c91b0d05ce53d41306fb9b28788bdc53115df8a3698f87e41f9d76e8dd548d804
6
+ metadata.gz: f9d730184e0b65c57e7a894abf10d26e2553e5b627d92ed211a9b93a7e3e1e163eb95ef3429ea837509e0d1caa5607efc29655446411b51111f90dddd7d7be59
7
+ data.tar.gz: 5256f3a310c2a8d5586477ee0a0f45c208a02b60ab0720632f26bcaf9b0fa428b546fa6b9ff825b2b8fc2d1e872e5939eefbda75036d93f3486b4485d3dbcbc7
@@ -0,0 +1,19 @@
1
+ module ActiveRecord
2
+ module ConnectionAdapters
3
+ # PostgreSQL-specific extensions to column definitions in a table.
4
+ class PostgreSQLColumn < Column #:nodoc:
5
+ # == Patch 1:
6
+ # Remove schema name part from table name when sequence name doesn't include it.
7
+ def serial?
8
+ return unless default_function
9
+
10
+ if %r{\Anextval\('"?(?<sequence_name>.+_(?<suffix>seq\d*))"?'::regclass\)\z} =~ default_function
11
+ is_schema_name_included = sequence_name.split(".").size > 1
12
+ _table_name = is_schema_name_included ? table_name : table_name.split(".").last
13
+
14
+ sequence_name_from_parts(_table_name, name, suffix) == sequence_name
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -15,6 +15,21 @@ module ActiveRecord
15
15
  # Regex to find where clause in index statements
16
16
  INDEX_WHERE_EXPRESSION = /WHERE (.+)$/
17
17
 
18
+ # Returns the list of all tables in the schema search path or a specified schema.
19
+ #
20
+ # == Patch:
21
+ # If current user is not `postgres` original method return all tables from all schemas
22
+ # without schema prefix. This disables such behavior by querying only default schema.
23
+ # Tables with schemas will be queried later.
24
+ #
25
+ def tables(name = nil)
26
+ query(<<-SQL, 'SCHEMA').map { |row| row[0] }
27
+ SELECT tablename
28
+ FROM pg_tables
29
+ WHERE schemaname = ANY (ARRAY['public'])
30
+ SQL
31
+ end
32
+
18
33
  # Returns an array of indexes for the given table.
19
34
  #
20
35
  # == Patch 1:
@@ -5,7 +5,10 @@ module PgSaurus
5
5
  initializer "pg_saurus" do
6
6
  ActiveSupport.on_load(:active_record) do
7
7
  # load monkey patches
8
- %w(schema_dumper errors connection_adapters/postgresql/schema_statements).each do |path|
8
+ %w(schema_dumper
9
+ errors
10
+ connection_adapters/postgresql/schema_statements
11
+ connection_adapters/postgresql/column).each do |path|
9
12
  require ::PgSaurus::Engine.root + "lib/core_ext/active_record/" + path
10
13
  end
11
14
 
@@ -1,4 +1,4 @@
1
1
  module PgSaurus
2
2
  # Version of pg_saurus gem.
3
- VERSION = "4.0.0"
3
+ VERSION = "4.0.1"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_saurus
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Potapov Sergey
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2019-10-24 00:00:00.000000000 Z
16
+ date: 2019-10-26 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: pg
@@ -214,6 +214,7 @@ files:
214
214
  - README.markdown
215
215
  - bin/rails
216
216
  - lib/colorized_text.rb
217
+ - lib/core_ext/active_record/connection_adapters/postgresql/column.rb
217
218
  - lib/core_ext/active_record/connection_adapters/postgresql/schema_statements.rb
218
219
  - lib/core_ext/active_record/errors.rb
219
220
  - lib/core_ext/active_record/schema_dumper.rb