pg_spec_helper 1.8.4 → 1.8.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8732b097aad7c3e1dec96adb1ed3b4e18785751fef23248383780e19980fc4d1
4
- data.tar.gz: e33a899e37af66b3b91fd49fbeb948ba64e2e5e1d921201d75094f5de4810282
3
+ metadata.gz: 80425037527e477dc7bbb76dbeba05d0a9339f6cf829ee1f9d17338c99bb3e95
4
+ data.tar.gz: b7a29ce7a34962211ce7100330754b9d10dc53c0910efd5d987c776b9ca9e819
5
5
  SHA512:
6
- metadata.gz: d4b0f4cbdce40c653211937809b9a0aa0dcc9650bbc278938ed1edaa0616cf0257f5e057784cf8940bd3bb749def9dfaa51dc33b1977b182fc4ea56c349881c7
7
- data.tar.gz: aa85da46f45732fb0b33b028d5348064f65cde89f42383adcb4bcea12b1af3a5066c837de8bf98690c4c0d2901d9a5e6eb42ef9a3e74af5c949e00e7495ac984
6
+ metadata.gz: a47cc3dc6c0744df722e420af888ffb552b6df4aeb44caeef0e8d5c6a8f25e4ec2218ac6f537caca7d23d891e09631aa8951b57934b5bea070a8535b21d22807
7
+ data.tar.gz: d255fd2adaffd140017ff8c8a8961e1251782b6bee1773ebaee283e86be75a5acbd70c5df5aa87a9f236266b34f9cffc331e07e0581958c62d4918e1f47d83f0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.8.5](https://github.com/craigulliott/pg_spec_helper/compare/v1.8.4...v1.8.5) (2023-08-19)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * removing the sanitization of sql data (it is useless in this gem, and gets in the way of testing some things, which defeats the point of this gem) ([fe6af3b](https://github.com/craigulliott/pg_spec_helper/commit/fe6af3bd4443b140a3136d43f1da61315de4d761))
9
+
3
10
  ## [1.8.4](https://github.com/craigulliott/pg_spec_helper/compare/v1.8.3...v1.8.4) (2023-08-18)
4
11
 
5
12
 
@@ -10,7 +10,7 @@ class PGSpecHelper
10
10
  # note the `type` is safe from sql_injection due to the validation above
11
11
  connection.exec(<<~SQL)
12
12
  ALTER TABLE #{connection.quote_ident schema_name.to_s}.#{connection.quote_ident table_name.to_s}
13
- ADD COLUMN #{connection.quote_ident column_name.to_s} #{sanitize_name type} #{null ? "" : "NOT NULL"}
13
+ ADD COLUMN #{connection.quote_ident column_name.to_s} #{type} #{null ? "" : "NOT NULL"}
14
14
  SQL
15
15
  end
16
16
 
@@ -4,14 +4,14 @@ class PGSpecHelper
4
4
  module ForeignKeys
5
5
  # Create a foreign key
6
6
  def create_foreign_key schema_name, table_name, column_names, foreign_schema_name, foreign_table_name, foreign_column_names, foreign_key_name
7
- column_names_sql = column_names.map { |n| sanitize_name n }.join(", ")
8
- foreign_column_names_sql = foreign_column_names.map { |n| sanitize_name n }.join(", ")
7
+ column_names_sql = column_names.join(", ")
8
+ foreign_column_names_sql = foreign_column_names.join(", ")
9
9
  # add the foreign key
10
10
  connection.exec(<<~SQL)
11
- ALTER TABLE #{sanitize_name schema_name}.#{sanitize_name table_name}
12
- ADD CONSTRAINT #{sanitize_name foreign_key_name}
11
+ ALTER TABLE #{schema_name}.#{table_name}
12
+ ADD CONSTRAINT #{foreign_key_name}
13
13
  FOREIGN KEY (#{column_names_sql})
14
- REFERENCES #{sanitize_name foreign_schema_name}.#{sanitize_name foreign_table_name} (#{foreign_column_names_sql})
14
+ REFERENCES #{foreign_schema_name}.#{foreign_table_name} (#{foreign_column_names_sql})
15
15
  SQL
16
16
  end
17
17
 
@@ -4,7 +4,7 @@ class PGSpecHelper
4
4
  module Indexes
5
5
  # Create an index
6
6
  def create_index schema_name, table_name, column_names, index_name
7
- column_names_sql = column_names.map { |n| sanitize_name n }.join(", ")
7
+ column_names_sql = column_names.join(", ")
8
8
  connection.exec(<<~SQL)
9
9
  CREATE INDEX #{connection.quote_ident index_name.to_s}
10
10
  ON #{connection.quote_ident schema_name.to_s}.#{connection.quote_ident table_name.to_s} (#{column_names_sql})
@@ -71,7 +71,7 @@ class PGSpecHelper
71
71
  # time the materialized view is found to exist, at which point the method
72
72
  # will always return true
73
73
  @materialized_views[schema_name.to_sym][materialized_view_name.to_sym][:exists] ||= connection.exec(<<~SQL).count > 0
74
- SELECT TRUE AS exists FROM pg_matviews WHERE schemaname = '#{sanitize_name schema_name}' AND matviewname = '#{sanitize_name materialized_view_name}';
74
+ SELECT TRUE AS exists FROM pg_matviews WHERE schemaname = '#{schema_name}' AND matviewname = '#{materialized_view_name}';
75
75
  SQL
76
76
  end
77
77
 
@@ -7,8 +7,8 @@ class PGSpecHelper
7
7
  column_names_sql = column_names.map { |n| connection.quote_ident n.to_s }.join(", ")
8
8
  # add the primary_key
9
9
  connection.exec(<<~SQL)
10
- ALTER TABLE #{sanitize_name schema_name.to_s}.#{sanitize_name table_name.to_s}
11
- ADD CONSTRAINT #{sanitize_name primary_key_name}
10
+ ALTER TABLE #{schema_name}.#{table_name}
11
+ ADD CONSTRAINT #{primary_key_name}
12
12
  PRIMARY KEY (#{column_names_sql})
13
13
  SQL
14
14
  end
@@ -11,7 +11,7 @@ class PGSpecHelper
11
11
 
12
12
  # return a list of the schema names in the database
13
13
  def get_schema_names
14
- ignored_schemas_sql = ignored_schemas.map { |n| sanitize_name n }.join("', '")
14
+ ignored_schemas_sql = ignored_schemas.join("', '")
15
15
  # return a list of the schema names from the database
16
16
  results = connection.exec(<<~SQL)
17
17
  SELECT schema_name
@@ -5,7 +5,7 @@ class PGSpecHelper
5
5
  # create a new table in the provided schema
6
6
  def create_table schema_name, table_name
7
7
  connection.exec(<<~SQL)
8
- CREATE TABLE #{sanitize_name schema_name.to_s}.#{sanitize_name table_name.to_s}(
8
+ CREATE TABLE #{schema_name}.#{table_name}(
9
9
  -- tables are created empty, and have columns added to them later
10
10
  );
11
11
  SQL
@@ -30,7 +30,7 @@ class PGSpecHelper
30
30
  -- temporarily set the client_min_messages to WARNING to
31
31
  -- suppress the NOTICE messages about cascading deletes
32
32
  SET client_min_messages TO WARNING;
33
- DROP TABLE #{sanitize_name schema_name.to_s}.#{sanitize_name table_name.to_s} CASCADE;
33
+ DROP TABLE #{schema_name}.#{table_name} CASCADE;
34
34
  SET client_min_messages TO NOTICE;
35
35
  SQL
36
36
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class PGSpecHelper
4
- VERSION = "1.8.4"
4
+ VERSION = "1.8.5"
5
5
  end
@@ -6,7 +6,6 @@ require "pg"
6
6
  require "pg_spec_helper/version"
7
7
 
8
8
  require "pg_spec_helper/connection"
9
- require "pg_spec_helper/sanitize"
10
9
  require "pg_spec_helper/ignored_schemas"
11
10
  require "pg_spec_helper/schemas"
12
11
  require "pg_spec_helper/tables"
@@ -31,7 +30,6 @@ class PGSpecHelper
31
30
  end
32
31
 
33
32
  include Connection
34
- include Sanitize
35
33
  include IgnoredSchemas
36
34
  include Schemas
37
35
  include Tables
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.8.4
4
+ version: 1.8.5
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-08-18 00:00:00.000000000 Z
11
+ date: 2023-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -62,7 +62,6 @@ files:
62
62
  - lib/pg_spec_helper/models.rb
63
63
  - lib/pg_spec_helper/primary_keys.rb
64
64
  - lib/pg_spec_helper/reset.rb
65
- - lib/pg_spec_helper/sanitize.rb
66
65
  - lib/pg_spec_helper/schemas.rb
67
66
  - lib/pg_spec_helper/table_executer.rb
68
67
  - lib/pg_spec_helper/tables.rb
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class PGSpecHelper
4
- module Sanitize
5
- class UnsafePostgresNameError < StandardError
6
- end
7
-
8
- # returns a sanitized version of the provided name, raises an error
9
- # if it is not valid
10
- #
11
- # this is probably unnessesary due to this gem being used within a test
12
- # suite and not a production application, but it is here for completeness
13
- # and an abundance of caution
14
- def sanitize_name name
15
- # ensure the name is a string
16
- name = name.to_s
17
- # ensure the name is not empty
18
- raise UnsafePostgresNameError, "name cannot be empty" if name.empty?
19
- # ensure the name does not contain invalid characters
20
- raise UnsafePostgresNameError, "name contains invalid characters" unless /\A[a-zA-Z0-9_-]+\z/.match?(name)
21
- # return the name
22
- name
23
- end
24
- end
25
- end