starnowski / posmulten

Posmulten library is an open-source project for the generation of SQL DDL statements that make it easy for implementation of Shared Schema Multi-tenancy strategy via the Row Security Policies in the Postgres database.
GNU Lesser General Public License v2.1
21 stars 11 forks source link

Create component which will create an identifier for Postgres objects like functions, policies, and constraints. #48

Open starnowski opened 4 years ago

starnowski commented 4 years ago

Create component which will create identifier for postgres objects like functions, policies and constraints.

PostgresIdentifier.produce(String... args)

Example:

producer.produce("is", "user_id", "from", "tenat") == "is_user_id_from_tenant"

The component should truncate the value to maximum length available in Postgres (by default it is 63 characters).

IMPORTANT! Create a component that will be able to check the value of NAMEDATALEN and if it's valid with the maximum value set in component responsible for identifier generation.

https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS

https://www.postgresql.org/message-id/20041101092011.GA26912%40svana.org

https://til.hashrocket.com/posts/8f87c65a0a-postgresqls-max-identifier-length-is-63-bytes

starnowski commented 4 years ago

Consider adding the interface (defined just like below), implemented by all the SQLDefinition objects.

interface HasSQLObjectsWithNames {

List<SQLObjectName> getSQLObjectNames();

}

SQLObjectName { String getName();

String getSchema();

}