@@ 128-161 (lines=34) @@ | ||
125 | * @return \PommProject\Foundation\ConvertedResultIterator|null |
|
126 | * @deprecated |
|
127 | */ |
|
128 | public function getTableFieldInformation($oid) |
|
129 | { |
|
130 | $sql = <<<SQL |
|
131 | select |
|
132 | att.attname as "name", |
|
133 | case |
|
134 | when name.nspname = 'pg_catalog' then typ.typname |
|
135 | else format('%s.%s', name.nspname, typ.typname) |
|
136 | end as "type", |
|
137 | def.adsrc as "default", |
|
138 | att.attnotnull as "is_notnull", |
|
139 | dsc.description as "comment", |
|
140 | att.attnum as "position", |
|
141 | att.attnum = any(ind.indkey) as "is_primary" |
|
142 | from |
|
143 | pg_catalog.pg_attribute att |
|
144 | join pg_catalog.pg_type typ on att.atttypid = typ.oid |
|
145 | join pg_catalog.pg_class cla on att.attrelid = cla.oid |
|
146 | left join pg_catalog.pg_description dsc on cla.oid = dsc.objoid and att.attnum = dsc.objsubid |
|
147 | left join pg_catalog.pg_attrdef def on att.attrelid = def.adrelid and att.attnum = def.adnum |
|
148 | left join pg_catalog.pg_index ind on cla.oid = ind.indrelid and ind.indisprimary |
|
149 | left join pg_catalog.pg_namespace name on typ.typnamespace = name.oid |
|
150 | where |
|
151 | {condition} |
|
152 | order by |
|
153 | att.attnum |
|
154 | SQL; |
|
155 | $where = Where::create('att.attrelid = $*', [$oid]) |
|
156 | ->andWhere('att.attnum > 0') |
|
157 | ->andWhere('not att.attisdropped') |
|
158 | ; |
|
159 | ||
160 | return $this->executeSql($sql, $where); |
|
161 | } |
|
162 | ||
163 | /** |
|
164 | * getSchemaOid |
@@ 140-175 (lines=36) @@ | ||
137 | * @param Where $where |
|
138 | * @return ConvertedResultIterator |
|
139 | */ |
|
140 | protected function getTableFieldInformationWhere(Where $where) |
|
141 | { |
|
142 | $sql = <<<SQL |
|
143 | select |
|
144 | att.attname as "name", |
|
145 | case |
|
146 | when name.nspname = 'pg_catalog' then typ.typname |
|
147 | else format('%s.%s', name.nspname, typ.typname) |
|
148 | end as "type", |
|
149 | def.adsrc as "default", |
|
150 | att.attnotnull as "is_notnull", |
|
151 | dsc.description as "comment", |
|
152 | att.attnum as "position", |
|
153 | att.attnum = any(ind.indkey) as "is_primary" |
|
154 | from |
|
155 | pg_catalog.pg_attribute att |
|
156 | join pg_catalog.pg_type typ on att.atttypid = typ.oid |
|
157 | join pg_catalog.pg_class cla on att.attrelid = cla.oid |
|
158 | join pg_catalog.pg_namespace clns on cla.relnamespace = clns.oid |
|
159 | left join pg_catalog.pg_description dsc on cla.oid = dsc.objoid and att.attnum = dsc.objsubid |
|
160 | left join pg_catalog.pg_attrdef def on att.attrelid = def.adrelid and att.attnum = def.adnum |
|
161 | left join pg_catalog.pg_index ind on cla.oid = ind.indrelid and ind.indisprimary |
|
162 | left join pg_catalog.pg_namespace name on typ.typnamespace = name.oid |
|
163 | where |
|
164 | {condition} |
|
165 | order by |
|
166 | att.attnum |
|
167 | SQL; |
|
168 | ||
169 | $where = $where |
|
170 | ->andWhere('att.attnum > 0') |
|
171 | ->andWhere('not att.attisdropped') |
|
172 | ; |
|
173 | ||
174 | return $this->executeSql($sql, $where); |
|
175 | } |
|
176 | ||
177 | /** |
|
178 | * getTableFieldInformation |