prick 0.39.10 → 0.39.11

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: ad50ce31807638ac2ae6641f51d77ed2b27fc4649dcfb103760f807c73b9abdd
4
+ data.tar.gz: e017f2e426eb63b8af62c1b5e88d39b662dac8a256db92274335edc50cf75aad
5
5
  SHA512:
6
- metadata.gz: 8b48ab4c8a4dc42df39d46a827279b6e413f04d1a1989c9aee4858e30e26a05dff7630cb22fe37f464c5e3ca3cbb3634061ed2e8cdc161b514defcdf7f9372e1
7
- data.tar.gz: 98e31722b962566506a7157acf72b9eeb523b68f9427f98e8b633e7e056fbe38e4c57886fa88341cde5e80285cd86e3fb5bf24eb3153d95ed74b6c0d097df371
6
+ metadata.gz: 23e42576bc05d4326feaffcbee16786be1957535d511959062036b7f6bb38ba43bb368ac2304c138b6cd23b40ba447c10f1a0a1b3dc5c00f4f03dee787c9843e
7
+ data.tar.gz: e0ef1c1700bf783efedbb37c20aad0c6e162543edf4bf5f2b889b8872f1282a1441a11725f8410c9c922388c1853dd12a496772332d16240ba432ba57b125837
@@ -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
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.11"
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.11
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-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: semantic