diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py index 01f961a..5720f17 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py @@ -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) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/templates/column/js/column.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/templates/column/js/column.js index a2a0413..1c5b9f6 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/templates/column/js/column.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/templates/column/js/column.js @@ -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', diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/datatype/sql/9.1_plus/get_types.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/datatype/sql/9.1_plus/get_types.sql index f465a46..4f04090 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/datatype/sql/9.1_plus/get_types.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/datatype/sql/9.1_plus/get_types.sql @@ -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 \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/utils.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/utils.py index b46a5a0..e10cf98 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/utils.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/utils.py @@ -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