pg_graph 0.5.1 → 0.5.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3605f3dc16a65459725b3890e9dc85d4c7f4bf3fbdbf216526a12a1c843ef6f7
4
- data.tar.gz: 34a6d5f23cf5914d43f53835f817aedb79f9699104c807d20d30fb9507633162
3
+ metadata.gz: c459728a41d81e623602fa57ad501d0471e674b398964a4c462b35ba38753fa4
4
+ data.tar.gz: c2f31952b99c64e13c197faff4f63b5c6dd0d2cbbc8e57fdd8afb8d3383d67a9
5
5
  SHA512:
6
- metadata.gz: e5e870b7ecd6ec71a8c0b8e5196511963402a372374efa003c522b847ec3b92ba50904c36046451930a79f6265455f0ba33f2f65547bd6b39a79ab88dc7ba30c
7
- data.tar.gz: ec4d637a227f5a94beda42b2075240e9ecc1d70af3eaf1fa3c9c9c7c4d5990f269b70751985aa17482f3210c3ffbb635ed92638f8d5b5d69906c7e57fcc9526e
6
+ metadata.gz: d4fe21aead7e99b9196586701edc291d521c5a71b4d94e1fdbe32b87471845bcaf34bbf802751cc86ccd80b4107f6a39f5f1138f0ded644b7480db92c64ebe4c
7
+ data.tar.gz: e30768a57d8c0fec136af5f772b1584f91a5cf0cf7f2616297d3eeb4a40e36cbbc7e42cd005f37a6f5540730e5b4db00ee7ce580e27a1aedd67513802fecb1c1
data/exe/pg_graph CHANGED
@@ -11,6 +11,8 @@ include ShellOpts
11
11
  SPEC = %(
12
12
  @ Load, dump, and clean databases
13
13
 
14
+ -- DATABASE
15
+
14
16
  pg_graph is a utility that uses the PgGraph module to load, dump, or clean a
15
17
  database. It uses a variety of formats that can be executed by psql(1)
16
18
  ('psql') or by the Postgres library exec() call ('exec', 'sql'). It can also
@@ -213,7 +213,8 @@ module PgGraph::Data
213
213
 
214
214
  def render_inserts
215
215
  @insert_records.map { |table, records|
216
- "insert into #{table.uid} (#{table.type.value_columns.map(&:name).join(', ')}) values " + \
216
+ "insert into #{table.uid} (#{table.type.value_columns.map(&:name).join(', ')})" + \
217
+ " overriding system value values " + \
217
218
  records.sort_by(&:id).map { |record|
218
219
  "(" +
219
220
  record.type.value_columns.map { |column_type|
@@ -2,6 +2,12 @@
2
2
  require 'constrain'
3
3
  require 'indented_io'
4
4
 
5
+ def putv(*variables)
6
+ for var in Array(variables)
7
+ puts "#{var}: #{self.send(var).inspect}"
8
+ end
9
+ end
10
+
5
11
  module PgGraph
6
12
  class Reflection
7
13
  # Textual representation of match RE (String)
@@ -41,6 +47,11 @@ module PgGraph
41
47
  # True if this is a default reflection
42
48
  attr_reader :default_reflection
43
49
 
50
+ def dump
51
+ puts "Reflection"
52
+ indent { putv :match, :re, :this, :that, :multi?, :pluralize, :components }
53
+ end
54
+
44
55
  # +this+ and +that+ are template strings, nil, or false
45
56
  def initialize(match, this, that, multi = nil, pluralize = nil, default_reflection = false)
46
57
  constrain match, Regexp, String
@@ -141,10 +152,11 @@ module PgGraph
141
152
 
142
153
  # Find 'that' field name for the given UID by searching through reflections
143
154
  # for a match. The name is pluralized if the matcher returns true or if the
144
- # matcher returns nil and unique is false The :table option can be used to
155
+ # matcher returns nil and unique is false. The :table option can be used to
145
156
  # override the table name in '$$' rules. This is used in N:M and M:M
146
- # relations. Returns nil if no match was found or if a matching reflection
147
- # has #continue equal to false
157
+ # relations. Returns false if the :that property is set to false in the
158
+ # reflections file. Returns nil if no match was found or if a matching
159
+ # reflection has #continue equal to false
148
160
  def that(uid, unique, multi = false, table: nil)
149
161
  constrain uid, String
150
162
  if (name, pluralize = do_match(uid, :that, multi, table: table))
@@ -202,6 +214,7 @@ module PgGraph
202
214
  conn.exec %(
203
215
  insert into #{schema}.#{table}
204
216
  (match, this, that, multi, pluralize, default_reflection, ordinal)
217
+ overriding system value
205
218
  values
206
219
  #{values}
207
220
  )
@@ -240,7 +253,7 @@ module PgGraph
240
253
  match_data = reflection.re.match(uid) or next
241
254
  template = reflection.send(kind).dup
242
255
  if template == false
243
- return nil
256
+ return [false, false]
244
257
  elsif template
245
258
  table ||= uid.split(".")[-2]
246
259
  template.gsub!(/\$\$/, table)
@@ -144,10 +144,10 @@ module PgGraph::Type
144
144
  else
145
145
  multi = reference_count[this_record_type][that_record_type] > 1
146
146
  name = reflector.that(uid, this_column.unique?, multi, table: this_record_type.name)
147
- name ||= PgGraph.inflector.pluralize(this_column.table.name) if this_column.kind?
147
+ name ||= PgGraph.inflector.pluralize(this_column.table.name) if name.nil? && this_column.kind?
148
148
  end
149
149
 
150
- next if name.nil?
150
+ next if !name
151
151
 
152
152
  # Check for name collisions
153
153
  if that_record_type.key?(name)
@@ -1,3 +1,3 @@
1
1
  module PgGraph
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_graph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.3
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-07-24 00:00:00.000000000 Z
11
+ date: 2025-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: boolean