Package org.pjdbc.sql
Class SchemaTransformer
java.lang.Object
org.pjdbc.sql.AbstractJdbcTransformer
org.pjdbc.sql.SchemaTransformer
- All Implemented Interfaces:
JdbcTransformer
Transformer that adds a schema prefix to table names in SQL.
Prefixes unqualified table names after FROM, JOIN, INTO, UPDATE, and TABLE keywords. Already-qualified names (containing a dot) are not modified.
URL Configuration
jdbc:filter[schema=tenant_123]:jdbc:postgresql://localhost/db
Examples
SELECT * FROM users→SELECT * FROM tenant_123.usersSELECT * FROM public.users→ unchanged (already qualified)INSERT INTO orders→INSERT INTO tenant_123.ordersUPDATE customers SET→UPDATE tenant_123.customers SET
Limitations
- Uses regex heuristics - may not handle all SQL dialects perfectly
- Does not parse SQL AST
- May prefix non-table identifiers if they follow table keywords
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSchemaTransformer(String schema) Create a SchemaTransformer with the specified schema prefix. -
Method Summary
Modifier and TypeMethodDescriptiontransformSql(String sql) Default implementation returns SQL unchanged.Methods inherited from class org.pjdbc.sql.AbstractJdbcTransformer
transformParameter, transformResultValue
-
Constructor Details
-
SchemaTransformer
Create a SchemaTransformer with the specified schema prefix.- Parameters:
schema- the schema to prefix table names with
-
-
Method Details
-
transformSql
Description copied from class:AbstractJdbcTransformerDefault implementation returns SQL unchanged.- Specified by:
transformSqlin interfaceJdbcTransformer- Overrides:
transformSqlin classAbstractJdbcTransformer- Parameters:
sql- Original SQL string- Returns:
- Transformed SQL string
- Throws:
SQLException- if transformation fails
-