prick 0.9.0 → 0.10.0

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: 3009c0da5619e908746d98eefe922851d886105d10b6bc49cc0295cf47a50033
4
- data.tar.gz: 3ee5cd54a3b29171306c3ad2fe8ea10c2e6d1ad84e1b8446b6314770c6734aef
3
+ metadata.gz: 8fa13b0150bd8e2a403643947215116be13d78d33f053e15c766a258574cf79e
4
+ data.tar.gz: 8b817641aff64c1ad488ce7562ac03a26c8d2144b3bf79999ef0af0ae910d298
5
5
  SHA512:
6
- metadata.gz: 7ee1ce2cd13293542db575cbbf5d955f542eff9b3cc6e4b87027800e7b0effb12ca134df2665f6a2a240cb0c191cd2fc9e5cca9b943c307591b499e75d27b5db
7
- data.tar.gz: 7f81e321f4875bce049b5adf7eb7fe7394a8112135d13b73ebdd48680b014329517e7137df419f504861a2d855243d37dfcafc2f67226fef57c537e28dd27dde
6
+ metadata.gz: 5b0896b4d9d38984cee6f3a3d6481ed4b9607c54101a120aaa4344b701ed649fe7ef5ca25bcb1214aa1802700e80e0bee41aa47157039f4f2774825d0af04f44
7
+ data.tar.gz: e19f8f4b6529bc1463f01fdcb5077ddfd55fe970ac062ef8fbbfd79dd31d1c8f74dcef759222cfdbaf4890158ef6b7993ddeb369d8c0499ead2265f20073769a
data/exe/prick CHANGED
@@ -251,7 +251,7 @@ begin
251
251
  program.save(version, file)
252
252
 
253
253
  when :drop
254
- program.drop(args.expect(0..1), opts.drop!.all)
254
+ program.drop(args.expect(0..1), opts.drop!.all?)
255
255
 
256
256
  when :diff
257
257
  mark = opts.diff!.mark
data/lib/prick/builder.rb CHANGED
@@ -20,6 +20,8 @@ module Prick
20
20
  # If a directory doesn't contain a build resource, the resources in the
21
21
  # directory are built in alphabetic order
22
22
  #
23
+ # Build SQL scripts are executed with search path set to containing schema
24
+ #
23
25
  class Builder
24
26
  attr_reader :database
25
27
  attr_reader :directory
@@ -57,11 +59,11 @@ module Prick
57
59
  Dir.chdir(dir) { yield(file) }
58
60
  end
59
61
 
60
- def do_sql(path)
62
+ def do_sql(path, schema: nil)
61
63
  # puts "do_sql(#{path})"
62
64
  do_dir(path) { |file|
63
65
  if @execute
64
- Rdbms.exec_file(database.name, file, user: database.user)
66
+ Rdbms.exec_file(database.name, file, user: database.user, schema: schema)
65
67
  else
66
68
  @lines += IO.readlines(file).map(&:chomp)
67
69
  end
@@ -159,6 +161,12 @@ module Prick
159
161
  end
160
162
 
161
163
  def self.yml_file(directory) File.join(directory, "build") + ".yml" end
164
+
165
+ protected
166
+ def do_sql(path)
167
+ schema = Dir.getwd.sub(/^.*schema\/([^\/]+)(?:\/.*)?$/, '\1')
168
+ super(path, schema: schema)
169
+ end
162
170
  end
163
171
  end
164
172
 
data/lib/prick/rdbms.rb CHANGED
@@ -4,16 +4,15 @@ require 'csv'
4
4
 
5
5
  module Prick
6
6
  module Rdbms
7
- # extend Ensure
8
-
9
7
  ### EXECUTE SQL
10
8
 
11
9
  # Execute the SQL statement and return stdout as an array of tuples
12
- def self.exec_sql(db, sql, user: ENV['USER'])
10
+ def self.exec_sql(db, sql, user: ENV['USER'], schema: nil)
11
+ schema ||= "public"
13
12
  stdout = Command.command %(
14
13
  {
15
14
  echo "set role #{user};"
16
- echo "set search_path to public;"
15
+ echo "set search_path to #{schema};"
17
16
  cat <<'EOF'
18
17
  #{sql}
19
18
  EOF
@@ -23,8 +22,8 @@ EOF
23
22
  end
24
23
 
25
24
  # Execute the given file and return stdout as an array of tuples
26
- def self.exec_file(db, file, user: ENV['USER'])
27
- self.exec_sql(db, File.read(file), user: user)
25
+ def self.exec_file(db, file, user: ENV['USER'], schema: nil)
26
+ self.exec_sql(db, File.read(file), user: user, schema: schema)
28
27
  end
29
28
 
30
29
  # Execute the SQL statement and return the result as an array of record tuples
data/lib/prick/version.rb CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # Required by gem
6
6
  module Prick
7
- VERSION = "0.9.0"
7
+ VERSION = "0.10.0"
8
8
  end
9
9
 
10
10
  # Project related code starts here
@@ -1,5 +1,3 @@
1
1
 
2
2
  drop schema if exists [<SCHEMA>] cascade;
3
3
  create schema [<SCHEMA>];
4
-
5
- set search_path to [<SCHEMA>];
@@ -1,5 +1,3 @@
1
1
 
2
2
  drop schema if exists prick cascade;
3
3
  create schema prick;
4
-
5
- set search_path to prick;
@@ -1,7 +1,6 @@
1
1
  # Default schema files
2
2
  #
3
3
  ---
4
- - schema
5
4
  - roles
6
5
  - types
7
6
  - tables
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prick
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-10 00:00:00.000000000 Z
11
+ date: 2021-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: shellopts
@@ -133,7 +133,6 @@ files:
133
133
  - share/schema/schema/prick/tables.sql
134
134
  - share/schema/schema/public/.keep
135
135
  - share/schema/schema/public/build.yml
136
- - share/schema/schema/public/schema.sql
137
136
  - test_assorted
138
137
  - test_feature
139
138
  - test_refactor
@@ -1,3 +0,0 @@
1
- set search_path to public;
2
-
3
-