Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don’t worry, you can still create the pull request.
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Commits on May 25, 2012
@hanshuebner hanshuebner Add SCHEMA-NAME argument to TABLE-DESCRIPTION
The SCHEMA-NAME argument can be used to restrict the columns that are
returned by the TABLE-DESCRIPTION to a certain schema.  By default,
columns from all schemata are returned.
3fc834d
@hanshuebner hanshuebner Documentation update for TABLE-DESCRIPTION change. dc17b19
Showing with 17 additions and 10 deletions.
  1. +4 −2 doc/postmodern.html
  2. +13 −8 postmodern/util.lisp
View
6 doc/postmodern.html
@@ -442,14 +442,16 @@
<p class="def">
<span>function</span>
<a name="table-description"></a>
- table-description (name)
+ table-description (name &amp;optional schema-name)
<br/>&#8594; list
</p>
<p class="desc">Returns a list of the fields in the named table.
Each field is represented by a list of three elements: the field
name, the type, and a boolean indicating whether the field may be
- null.</p>
+ null. Optionally, schema-name can be specified to restrict the
+ result to fields from the named schema. Without it, all fields in
+ the table are returned, regardless of their schema.</p>
<p class="def">
<span>function</span>
View
21 postmodern/util.lisp
@@ -57,15 +57,20 @@ if strings-p is not true."
the view name."
(query (make-exists-query "v" view) :single))
-(defun table-description (table)
+(defun table-description (table &optional schema-name)
"Return a list of (name type null-allowed) lists for the fields of a
-table."
- (query (:select 'attname 'typname (:not 'attnotnull)
- :from 'pg-catalog.pg-attribute
- :inner-join 'pg-catalog.pg-type :on (:= 'pg-type.oid 'atttypid)
- :inner-join 'pg-catalog.pg-class :on (:and (:= 'pg-class.oid 'attrelid)
- (:= 'pg-class.relname (to-identifier table)))
- :where (:> 'attnum 0))))
+table. If SCHEMA-NAME is specified, only fields from that schema are
+returned."
+ (let ((schema-name (or schema-name "")))
+ (query (:select 'attname 'typname (:not 'attnotnull) :distinct
+ :from 'pg-catalog.pg-attribute
+ :inner-join 'pg-catalog.pg-type :on (:= 'pg-type.oid 'atttypid)
+ :inner-join 'pg-catalog.pg-class :on (:and (:= 'pg-class.oid 'attrelid)
+ (:= 'pg-class.relname (to-identifier table)))
+ :inner-join 'pg-catalog.pg-namespace :on (:= 'pg-namespace.oid 'pg-class.relnamespace)
+ :where (:and (:> 'attnum 0)
+ (:or (:= schema-name "")
+ (:= 'pg-namespace.nspname schema-name)))))))
(defclass transaction-handle ()
((open-p :initform t :accessor transaction-open-p)

No commit comments for this range

Something went wrong with that request. Please try again.