prick 0.39.10 → 0.39.12

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: d21f671634521afdb6a2f711b98042f5561496f45fcbfc75446a622cc4f0209c
4
- data.tar.gz: cd77bebc7e51297f7a768ae7b3d15267ea0591a8a9338ca73ba9d4e04589f6e3
3
+ metadata.gz: 5ebdfba60b4161b0afa671e4c19abf963db5d017376c089acade485e5d895dc8
4
+ data.tar.gz: a3cff45e06c66cb094fa3ca891b4d3a863d21ab52f2fb13ff1b9c2d026bb494b
5
5
  SHA512:
6
- metadata.gz: 8b48ab4c8a4dc42df39d46a827279b6e413f04d1a1989c9aee4858e30e26a05dff7630cb22fe37f464c5e3ca3cbb3634061ed2e8cdc161b514defcdf7f9372e1
7
- data.tar.gz: 98e31722b962566506a7157acf72b9eeb523b68f9427f98e8b633e7e056fbe38e4c57886fa88341cde5e80285cd86e3fb5bf24eb3153d95ed74b6c0d097df371
6
+ metadata.gz: 16a1deeabd509f289eeb1fff91a2880e21794bd1124862b84f0fd9c4cad19c512d22d2733ac9cd7b9bf0b288f536739cd9b1c1da88b002f1e2c4ceb9dd2c677a
7
+ data.tar.gz: 477ce9af0329c7b07a89be381f73cf47629f97b38395342dc817b0ccc051b20b1381da92e6bd71ed9cebb0f8a0b6e9a559eeaf7944b980f1c215d440f0d56f6f
@@ -35,23 +35,24 @@ module Prick
35
35
  def execute
36
36
  # puts "#execute"
37
37
  super {
38
- begin
39
- sql = []
40
- file = nil
41
- node = nil
38
+ file = nil
39
+ node = nil
42
40
 
41
+ begin
43
42
  # A SQL batch allows the first node to be an evaluated or executed node
44
43
  if nodes.first.is_a?(CommandNode)
45
44
  node = nodes.shift
46
- sql = [node.source]
45
+ conn.execute [node.source], silent: true
47
46
  end
47
+ rescue PG::Error => ex
48
+ error, line, char = conn.err
49
+ raise PostgresError.new("Error from #{node.to_s} at #{line}:#{char} - #{error}")
50
+ end
48
51
 
49
- conn.execute sql, silent: true if !sql.empty?
52
+ begin
50
53
  for node in nodes # This is marginally faster than concatenating all nodes
51
- # puts node.source
52
54
  conn.execute node.source, silent: true
53
55
  end
54
-
55
56
  rescue PG::Error => ex
56
57
  error, line, char = conn.err
57
58
  file = nil
@@ -123,6 +123,7 @@ module Prick
123
123
  def self.objects() @@objects end
124
124
  end
125
125
 
126
+ # Virtual base class for EvalNode and ExecNode
126
127
  class CommandNode < Node
127
128
  alias_method :command, :to_s
128
129
 
@@ -146,14 +147,16 @@ module Prick
146
147
  end
147
148
  end
148
149
 
150
+ # EvalNode executes the command and feeds the output into the database
149
151
  class EvalNode < CommandNode
150
152
  def read_source
151
153
  sql = execute_command
152
154
  @source_lines = 1 + 1 + sql.count("\n")
153
- ["set search_path to #{schema}, pg_temp;\n", sql]
155
+ ["set search_path to #{schema}, pg_temp", sql.join("\n")]
154
156
  end
155
157
  end
156
158
 
159
+ # ExecNode executes the command and ignores its output
157
160
  class ExecNode < CommandNode
158
161
  def read_source
159
162
  execute_command
@@ -57,7 +57,7 @@ module Prick
57
57
  unit = make_build_unit(parent, path)
58
58
  entries = YAML.load(File.read(path)) || []
59
59
  entries.each { |entry|
60
- if entry.is_a?(Hash) && (entry.size != 1 || entry.first.first != "sql")
60
+ if entry.is_a?(Hash) && (entry.size != 1 || !%w(call sql exec eval).include?(entry.first.first))
61
61
  entry.each { |key, value|
62
62
  if key == "schema"
63
63
  unit.schema = value
@@ -195,7 +195,7 @@ module Prick
195
195
 
196
196
  last = nil
197
197
  for env in [env] + env.ancestors.reverse
198
- bash_vars["ENVIRONMENT"] = env.name
198
+ bash_vars["PRICK_ENVIRONMENT"] = env.name
199
199
  file = expand_variables(filename, bash_vars)
200
200
  # last ||= (file != last and file) or return nil # return if no ENVIRONMENT substitution
201
201
  path = (file.start_with?("/") ? file : File.join(dir, file))
data/lib/prick/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Prick
4
- VERSION = "0.39.10"
4
+ VERSION = "0.39.12"
5
5
  end
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.39.10
4
+ version: 0.39.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-21 00:00:00.000000000 Z
11
+ date: 2024-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: semantic