Skip to content

Implement the usage of synonyms while parsing query expressions #155

Description

@kbarbounakis

Data objects synonyms are being used by MSSQL server for declaring aliases when using data objects inside SQL expressions e.g.

CREATE SYNONYM MyProduct
FOR AdventureWorks2022.Production.Product;
GO

-- Query the Product table by using the synonym.
SELECT ProductID, Name
FROM MyProduct
WHERE ProductID < 5;

This operation is not supported by other database engines like PostgreSQL, MySQL, Sqlite etc and should be supported by an agnostic SQL parser like SqlFormatter.

Solution

  • SqlFormatter might use @themost/events#SyncSeriesEventEmitter for allowing event subscription during SqlFormatter.escapeName for allowing subscribers to modify the result of this function.
  • The above might be controlled by a service e.g. SqlSynonym which will allow adding synonyms at process or application level.
  • SqlFormatter subclasses should folllow this spec for allowing the parsing of data objects names.

Activity

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

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions