mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Offer the various serial pseudo-types as column type options. Fixes #1393
This commit is contained in:
committed by
Dave Page
parent
53434030c1
commit
8246fc56e8
@@ -1129,7 +1129,7 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
'get_types_where_condition.sql']),
|
||||
show_system_objects=self.blueprint.show_system_objects)
|
||||
|
||||
status, types = self.get_types(self.conn, condition)
|
||||
status, types = self.get_types(self.conn, condition, True)
|
||||
|
||||
if not status:
|
||||
return internal_server_error(errormsg=types)
|
||||
|
||||
@@ -327,8 +327,14 @@ function($, _, S, pgAdmin, pgBrowser, Backform, alertify) {
|
||||
}
|
||||
},{
|
||||
id: 'defval', label:'{{ _('Default Value') }}', cell: 'string',
|
||||
type: 'text', disabled: 'inSchemaWithColumnCheck',
|
||||
group: '{{ _('Definition') }}'
|
||||
type: 'text', group: '{{ _('Definition') }}', deps: ['cltype'],
|
||||
disabled: function(m) {
|
||||
if(!m.inSchemaWithModelCheck.apply(this, [m])) {
|
||||
var type = m.get('cltype');
|
||||
return type == 'serial' || type == 'bigserial'
|
||||
|| type == 'smallserial';
|
||||
}
|
||||
}
|
||||
},{
|
||||
id: 'attnotnull', label:'{{ _('Not NULL?') }}', cell: 'string',
|
||||
type: 'switch', disabled: 'inSchemaWithColumnCheck',
|
||||
|
||||
@@ -15,5 +15,11 @@ FROM
|
||||
(NOT (typname = 'unknown' AND nspname = 'pg_catalog'))
|
||||
AND
|
||||
{{ condition }}
|
||||
{% if add_serials %}
|
||||
{# Here we will add serials types manually #}
|
||||
UNION SELECT 'smallserial', 0, 2, 'b', 0, 'pg_catalog', false, false
|
||||
UNION SELECT 'bigserial', 0, 8, 'b', 0, 'pg_catalog', false, false
|
||||
UNION SELECT 'serial', 0, 4, 'b', 0, 'pg_catalog', false, false
|
||||
{% endif %}
|
||||
) AS dummy
|
||||
ORDER BY nspname <> 'pg_catalog', nspname <> 'public', nspname, 1
|
||||
@@ -75,13 +75,14 @@ class DataTypeReader:
|
||||
- Returns data-types on the basis of the condition provided.
|
||||
"""
|
||||
|
||||
def get_types(self, conn, condition):
|
||||
def get_types(self, conn, condition, add_serials=False):
|
||||
"""
|
||||
Returns data-types including calculation for Length and Precision.
|
||||
|
||||
Args:
|
||||
conn: Connection Object
|
||||
condition: condition to restrict SQL statement
|
||||
add_serials: If you want to serials type
|
||||
"""
|
||||
res = []
|
||||
try:
|
||||
@@ -91,7 +92,8 @@ class DataTypeReader:
|
||||
|
||||
SQL = render_template("/".join([sql_template_path,
|
||||
'get_types.sql']),
|
||||
condition=condition)
|
||||
condition=condition,
|
||||
add_serials=add_serials)
|
||||
status, rset = conn.execute_2darray(SQL)
|
||||
if not status:
|
||||
return status, rset
|
||||
@@ -235,7 +237,6 @@ class DataTypeReader:
|
||||
else:
|
||||
return name + length + array
|
||||
|
||||
|
||||
def trigger_definition(data):
|
||||
"""
|
||||
This function will set the trigger definition details from the raw data
|
||||
|
||||
Reference in New Issue
Block a user