pg_meta 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pg_meta/meta.rb +26 -2
- data/lib/pg_meta/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 639796a952d70d81145a60347703f86b76ad212b000ad3ee4f960149fc339d24
|
4
|
+
data.tar.gz: 708a09c0e74d73810c58857b6234a24f20243fecce5bc4f39d6f7ec503ea6e8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42d3961c683c059659a7ede8264906ac2fb6767019d0878bc5d89ed86e0461a0f04c4185bca884bbcab300ca296d087e63e07c8176c4b56629f8c05c451ab374
|
7
|
+
data.tar.gz: 19ef7dc2f2f23efd49ddb7391f3816bbc639cce626b953d28b31d167ad55e2f7661e0d8fcf9106b6d1c266ce48f54a448f989c97a290070d4b5ceab00e79610a
|
data/lib/pg_meta/meta.rb
CHANGED
@@ -2,20 +2,28 @@ require 'yaml'
|
|
2
2
|
|
3
3
|
module PgMeta
|
4
4
|
class Node
|
5
|
-
# Database object. Equal to self for Database objects
|
5
|
+
# Database object. Equal to self for Database objects. TODO: Rename 'database'
|
6
6
|
attr_reader :root
|
7
7
|
|
8
8
|
# Parent object. nil for Database objects
|
9
9
|
attr_reader :parent
|
10
10
|
|
11
11
|
# Unique name within parent context. This is usually what we understand as
|
12
|
-
# the name of an object but functions have the full signature as "name"
|
12
|
+
# the name of an object but functions have the full signature as "name",
|
13
|
+
# eg. 'func(integer)'
|
13
14
|
attr_reader :name
|
14
15
|
|
16
|
+
# Unique id within a schema. Only tables, columns, and functions have a sid
|
17
|
+
def sid()
|
18
|
+
@sid = nil
|
19
|
+
end
|
20
|
+
|
21
|
+
# Unique id within a database. The database object itself has a nil uid
|
15
22
|
def uid()
|
16
23
|
@uid ||= [parent.uid, name].compact.join(".")
|
17
24
|
end
|
18
25
|
|
26
|
+
# Unique id within a RDBMS
|
19
27
|
def guid()
|
20
28
|
@guid ||= [parent.guid, name].compact.join(".")
|
21
29
|
end
|
@@ -134,6 +142,9 @@ module PgMeta
|
|
134
142
|
database.schemas[name] = self
|
135
143
|
end
|
136
144
|
|
145
|
+
# Lookup schema objects by sid
|
146
|
+
def [](sid) = database["#{uid}.#{sid}"]
|
147
|
+
|
137
148
|
# True if schema is hidden. This can be set dynamically
|
138
149
|
def hidden?() @hidden end
|
139
150
|
|
@@ -154,6 +165,8 @@ module PgMeta
|
|
154
165
|
# Schema of the table
|
155
166
|
alias_method :schema, :parent
|
156
167
|
|
168
|
+
alias_method :sid, :name
|
169
|
+
|
157
170
|
# True iff table is a real table and not a view
|
158
171
|
def table?() true end
|
159
172
|
|
@@ -182,6 +195,9 @@ module PgMeta
|
|
182
195
|
end
|
183
196
|
end
|
184
197
|
|
198
|
+
# Lookup column by name
|
199
|
+
def [](name) = @columns[name]
|
200
|
+
|
185
201
|
# List of primary key columns
|
186
202
|
#
|
187
203
|
# Note: Assigned by PrimaryKeyConstraint#initialize
|
@@ -296,6 +312,10 @@ module PgMeta
|
|
296
312
|
end
|
297
313
|
|
298
314
|
class Column < Node
|
315
|
+
def sid()
|
316
|
+
@sid ||= "#{table.name}.#{name}"
|
317
|
+
end
|
318
|
+
|
299
319
|
# Table of the column
|
300
320
|
alias_method :table, :parent
|
301
321
|
|
@@ -495,6 +515,10 @@ module PgMeta
|
|
495
515
|
end
|
496
516
|
|
497
517
|
class Function < Node
|
518
|
+
def sid()
|
519
|
+
@sid ||= name
|
520
|
+
end
|
521
|
+
|
498
522
|
# Schema of the function
|
499
523
|
alias_method :schema, :parent
|
500
524
|
|
data/lib/pg_meta/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_meta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.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:
|
11
|
+
date: 2023-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: indented_io
|