gadget 0.6.0 → 0.6.1

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
  SHA1:
3
- metadata.gz: b2bf83e177e0c22d39fbdd338c5df052bcf7ea6e
4
- data.tar.gz: 092f282fbacd8cb1858bbf96fff28e4cd74033e6
3
+ metadata.gz: 871bc48234116c2a7488eba4a4a354c3cb8d4961
4
+ data.tar.gz: 74561ca3469ef7dbc9f5acc8e5d7813a39daa5a4
5
5
  SHA512:
6
- metadata.gz: e4dd82afa75702c5c8953d4dceb7086cde36b787365d61e0a6441f6edd25e79fc3322ac92654a60972279ff9988b3f470618f95bf78883ecccf66296cfd7c564
7
- data.tar.gz: ee495b40222d0a17d18864d526ea84af4e2721204b016fe6639e8870093423dc49c974872ecdda070162cad9271bb536d475a4af3ad8d9c8877dab293944fc25
6
+ metadata.gz: e671d7aaf1b8227c5811967c7abb3355de0d72323f3bb1104405a22e8caaba24dd0bbe4fabbd1def1145b5955c8434bf2f4625d82ae5e938f0f02257858560ee
7
+ data.tar.gz: 0a9135347a3cdf0cc941ab753f2584d33df9dfa73041f3211e555cb175edd8458d559f8f9b729c8356f433a2caa798830f030a93cd282ff72e915a59d0a85e52
data/Rakefile CHANGED
@@ -1 +1,9 @@
1
1
  require "bundler/gem_tasks"
2
+
3
+ task :console do
4
+ require 'irb'
5
+ require 'irb/completion'
6
+ require 'gadget'
7
+ ARGV.clear
8
+ IRB.start
9
+ end
data/lib/gadget.rb CHANGED
@@ -82,22 +82,26 @@ WHERE t.schemaname='public'
82
82
  def self.columns(conn, *args)
83
83
  options = args.extract_options!
84
84
  tablename = args.shift
85
+ nspname = args.shift || "public"
85
86
 
86
87
  sql = <<-END_OF_SQL
87
- SELECT t.tablename, a.attname
88
+ SELECT t.tablename, a.attname, ns.nspname
88
89
  FROM pg_catalog.pg_attribute a
89
90
  INNER JOIN pg_catalog.pg_class c ON a.attrelid = c.oid
90
91
  INNER JOIN pg_catalog.pg_tables t ON c.relname = t.tablename
92
+ INNER JOIN pg_catalog.pg_namespace ns ON c.relnamespace = ns.oid
91
93
  WHERE a.attnum >= 0
94
+ AND t.schemaname = ns.nspname
95
+ AND ns.nspname = $1
92
96
  END_OF_SQL
93
97
  unless options[:include_dropped]
94
98
  sql += " AND a.attisdropped IS FALSE"
95
99
  end
96
100
  if tablename.nil?
97
- rs = conn.exec(sql)
101
+ rs = conn.exec_params(sql, [ nspname ])
98
102
  else
99
- sql += " AND t.tablename = $1"
100
- rs = conn.exec_params(sql, [ tablename ])
103
+ sql += " AND t.tablename = $2"
104
+ rs = conn.exec_params(sql, [ nspname, tablename ])
101
105
  end
102
106
  tuples = rs.reduce({}) do | h, row |
103
107
  h[row['tablename']] ||= { :columns => [] }
@@ -1,3 +1,3 @@
1
1
  module Gadget
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gadget
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig S. Cottingham
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-26 00:00:00.000000000 Z
11
+ date: 2014-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg