Skip to content

Add table_schema query and checks#2722

Open
dbauszus-glx wants to merge 16 commits intoGEOLYTIX:minorfrom
dbauszus-glx:table_schema
Open

Add table_schema query and checks#2722
dbauszus-glx wants to merge 16 commits intoGEOLYTIX:minorfrom
dbauszus-glx:table_schema

Conversation

@dbauszus-glx
Copy link
Copy Markdown
Member

This PR adds a table_schema query to the XYZ core queries.

The smallest definition of a layer [template] is with a table and dbs. Although the workspace fallback will be used if not explicit in the template.

  "templates": {
    "foo": {
      "dbs": "MAPP",
      "table": "geodata.uk_glx_geodata_oa_metrics_2021"
    }
  },

The templateTables method has been updated to allow for the table name to pass without the schema.

The schema and table params can now be defined for the table_schema query.

http://localhost:3000/api/query?template=table_schema&table_schema=geodata&table=uk_glx_geodata_oa_metrics_2021&layer=foo

The schema is returned as an array:

[
  {
    "column_name": "id",
    "data_type": "integer",
    "udt_name": "int4",
    "character_maximum_length": null,
    "column_default": null,
    "is_nullable": "NO"
  },
  {
    "column_name": "oa_code",
    "data_type": "text",
    "udt_name": "text",
    "character_maximum_length": null,
    "column_default": null,
    "is_nullable": "YES"
  },
  {
    "column_name": "lsoa_id",
    "data_type": "integer",
    "udt_name": "int4",
    "character_maximum_length": null,
    "column_default": null,
    "is_nullable": "YES"
  },
image

@dbauszus-glx dbauszus-glx self-assigned this Mar 20, 2026
@dbauszus-glx dbauszus-glx added Bug A genuine bug. There must be some form of error exception to work with. Feature New feature requests or changes to the behaviour or look of existing application features. Code Issues related to the code structure and performance. RFC Request for Comment or Change. and removed RFC Request for Comment or Change. labels Mar 20, 2026
@dbauszus-glx dbauszus-glx linked an issue Mar 20, 2026 that may be closed by this pull request
@dbauszus-glx
Copy link
Copy Markdown
Member Author

dbauszus-glx commented Mar 23, 2026

The query module structure has been revised. The executeQuery method was unnecessary complex. This method has now been resolved into the query method.

The checkFieldsParam method has been added to the layerQuery method to ensure that any field in the fields param is referenced in the layer object of a layer query.

The methods to replace variables in query template strings with string or substitute variables have now been unnested and documented.

Request params are now consistently assigned to the template object if not defined on the template ??=.

All params, and properties should now be documented.

The dbs check should be made before compiling the query [string] in the getQueryFromTemplate method.

@dbauszus-glx dbauszus-glx added the Documentation Adding or updating documentation. label Mar 23, 2026
@dbauszus-glx dbauszus-glx marked this pull request as ready for review March 25, 2026 19:30
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug A genuine bug. There must be some form of error exception to work with. Code Issues related to the code structure and performance. Documentation Adding or updating documentation. Feature New feature requests or changes to the behaviour or look of existing application features.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Layer [table] role restricted schema discovery

2 participants