raka 0.3.12 → 0.3.13

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/raka/lang/psql/impl.rb +7 -6
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82c1ea1afe876bee1942b2e05d450943a658325fe071e3cd6916ca2aa49ee664
4
- data.tar.gz: 70db8390dd89d1d61946a0697ee7e341a05ecd5e15682e48c0563548cafd0634
3
+ metadata.gz: e7433868304f673611a2ce9b5e847a8a78cd6bbd0be86fe18d576090acf7009f
4
+ data.tar.gz: ebe65786208dfd8bf1e35ea83a6ad625279018aa3a73df14599392bbaa91d684
5
5
  SHA512:
6
- metadata.gz: '02229d81b61a684a31aeda0cb6c8a3c665d31f2272091cbbb0c261272c73cbbdcebe1bb75c4e72fb4f89bf50d207614ff014ca04c0c16941bcc5fb907b3e2331'
7
- data.tar.gz: 479b43bc7e0167a33013b33fb307ea7adeed17ca80b4a2528721d48befc198dfd4cf92f37880372f50fd9905d8a30722d745ca0a5e5c7ff1a0d66dab31527467
6
+ metadata.gz: d8498aa76cd3a4ec7277fb0d7e7618c030c70cab306258bec7b5806c0da249108943e56f2b78bf41eb9fddc54d0f0aada4cfb21e59abca81db5dc8fc7495f18c
7
+ data.tar.gz: 7eef06176d02da633b5fc2138d675ec66809f479a84e155800f25d6797ed0aa463a58d76a77d1540d1d6b9eb8c6abfed39d60f78881344634cbd37610fdae579
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.12
1
+ 0.3.13
@@ -17,9 +17,9 @@ end
17
17
  # postgresql protocol using psql, requires HOST, PORT, USER, DB
18
18
  class Psql
19
19
  # Sometimes we want to use the psql command with bash directly
20
- def sh_cmd(scope)
20
+ def sh_cmd(schema)
21
21
  c = @conn
22
- env_vars = "PGOPTIONS='-c search_path=#{scope.empty? ? '' : scope + ','}public' "
22
+ env_vars = "PGOPTIONS='-c search_path=#{schema.empty? ? '' : schema + ','}public' "
23
23
  "PGPASSWORD=#{c.password} #{env_vars} psql -h #{c.host} -p #{c.port} -U #{c.user} -d #{c.db} -v ON_ERROR_STOP=1"
24
24
  end
25
25
 
@@ -35,10 +35,10 @@ class Psql
35
35
  raise 'argument conn required' if @conn.nil?
36
36
 
37
37
  if @create.to_s == 'table'
38
- 'DROP TABLE IF EXISTS :_name_;' \
38
+ 'DROP TABLE IF EXISTS :_schema_.:_name_;' \
39
39
  'CREATE TABLE :_name_ AS (' + code + ');'
40
40
  elsif @create.to_s == 'mview'
41
- 'DROP MATERIALIZED VIEW IF EXISTS :_name_;' \
41
+ 'DROP MATERIALIZED VIEW IF EXISTS :_schema_.:_name_;' \
42
42
  'CREATE MATERIALIZED VIEW :_name_ AS (' + code + ');'
43
43
  else
44
44
  code
@@ -47,10 +47,11 @@ class Psql
47
47
 
48
48
  def run_script(env, fname, task)
49
49
  param_str = (@params || {}).map { |k, v| "-v #{k}=\"#{v}\"" }.join(' ')
50
+ schema = task.rule_scopes.join('__')
50
51
 
51
52
  bash env, %(
52
- #{sh_cmd(task.rule_scopes.join('__'))} #{param_str} -v _name_=#{task.output_stem} \
53
- -f #{fname} | tee #{fname}.log
53
+ #{sh_cmd(schema)} #{param_str} -v _name_=#{task.output_stem} \
54
+ -v _schema_=#{schema} -f #{fname} | tee #{fname}.log
54
55
  mv #{fname}.log #{task.name}
55
56
  )
56
57
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.12
4
+ version: 0.3.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - yarray
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-26 00:00:00.000000000 Z
11
+ date: 2022-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake