pg_spec_helper 1.9.10 → 1.9.12
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 +4 -4
- data/CHANGELOG.md +14 -0
- data/lib/pg_spec_helper/columns.rb +11 -0
- data/lib/pg_spec_helper/version.rb +1 -1
- data/lib/pg_spec_helper.rb +11 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05407ffbeaaecf32054b8058325079e85e466a27c0caf79607a13844b2cb4353
|
4
|
+
data.tar.gz: '079c652b019f5e61536c26fd1b05cc0fa81ec69847fa0305194a864bd9203a07'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec42ef083b0c843178a8cde8c8be08bf47efe4503a36d780a3979e1c9421b142e4517523aba35a5eae1b4df4c886abb1d46ccbeb9e0e6b6ad5eb372d5664fe6c
|
7
|
+
data.tar.gz: b992a3bf513f94ca851c7131398b529301c061e0a58336129bf9061f184deeeccf71070e8aa642a5056d81dab6d6cf404728df00b4a3144d4f8ef9584a959230
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [1.9.12](https://github.com/craigulliott/pg_spec_helper/compare/v1.9.11...v1.9.12) (2023-10-09)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* accepting both `database` and `dbname` as the name of the database and both `user` and `username` as the name of the user. This covers the naming conventions from both the PG gem and ActiveRecord. ([2f43555](https://github.com/craigulliott/pg_spec_helper/commit/2f435555e1789ecd002f4c22b4feb6f4d2b8cb56))
|
9
|
+
|
10
|
+
## [1.9.11](https://github.com/craigulliott/pg_spec_helper/compare/v1.9.10...v1.9.11) (2023-09-01)
|
11
|
+
|
12
|
+
|
13
|
+
### Bug Fixes
|
14
|
+
|
15
|
+
* automatically add the citext extension if a column requires it ([0282269](https://github.com/craigulliott/pg_spec_helper/commit/028226916532ec135c47fe59540f556203d9964f))
|
16
|
+
|
3
17
|
## [1.9.10](https://github.com/craigulliott/pg_spec_helper/compare/v1.9.9...v1.9.10) (2023-08-25)
|
4
18
|
|
5
19
|
|
@@ -7,6 +7,17 @@ class PGSpecHelper
|
|
7
7
|
|
8
8
|
# create a column for the provided table
|
9
9
|
def create_column schema_name, table_name, column_name, type, null = true, default = nil
|
10
|
+
# required extension for citext
|
11
|
+
if type.to_sym == :citext
|
12
|
+
connection.exec(<<~SQL)
|
13
|
+
-- temporarily set the client_min_messages to WARNING to
|
14
|
+
-- suppress the NOTICE messages about extension already existing
|
15
|
+
SET client_min_messages TO WARNING;
|
16
|
+
CREATE EXTENSION IF NOT EXISTS "citext";
|
17
|
+
SET client_min_messages TO NOTICE;
|
18
|
+
SQL
|
19
|
+
end
|
20
|
+
|
10
21
|
# note the `type` is safe from sql_injection due to the validation above
|
11
22
|
connection.exec(<<~SQL)
|
12
23
|
ALTER TABLE #{connection.quote_ident schema_name.to_s}.#{connection.quote_ident table_name.to_s}
|
data/lib/pg_spec_helper.rb
CHANGED
@@ -53,17 +53,23 @@ class PGSpecHelper
|
|
53
53
|
|
54
54
|
attr_reader :database, :username, :password, :host, :port
|
55
55
|
|
56
|
-
def initialize
|
56
|
+
def initialize host:, port:, database: nil, dbname: nil, user: nil, username: nil, password: nil
|
57
|
+
# for simplicity, we accept both `database` and `dbname` as the name of the database
|
58
|
+
# and both `user` and `username` as the name of the user
|
59
|
+
# this covers the naming conventions from both the PG gem and ActiveRecord
|
60
|
+
provided_database = dbname || database
|
61
|
+
provided_username = user || username
|
62
|
+
|
57
63
|
# assert that all required options are present
|
58
|
-
raise MissingRequiredOptionError, "database is required" if
|
64
|
+
raise MissingRequiredOptionError, "database is required" if provided_database.nil?
|
59
65
|
raise MissingRequiredOptionError, "host is required" if host.nil?
|
60
|
-
raise MissingRequiredOptionError, "username is required" if
|
66
|
+
raise MissingRequiredOptionError, "username is required" if provided_username.nil?
|
61
67
|
|
62
68
|
# record the configuration
|
63
|
-
@database =
|
69
|
+
@database = provided_database
|
64
70
|
@host = host
|
65
71
|
@port = port || 5432
|
66
|
-
@username =
|
72
|
+
@username = provided_username
|
67
73
|
# password is optional
|
68
74
|
@password = password
|
69
75
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_spec_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.9.
|
4
|
+
version: 1.9.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Craig Ulliott
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|