Skip to content

Conversation

@montanalow
Copy link

Summary

This PR fixes an issue where schema-qualified table names (e.g., schema.table) were being incorrectly quoted in generated SQL.

The Problem

When using a table name like yahoo.exchanges:

#[derive(ormx::Table)]
#[ormx(table = "yahoo.exchanges", id = id)]
struct Exchange { ... }

The generated SQL would quote the entire name as "yahoo.exchanges", which PostgreSQL interprets as a single identifier containing a literal dot character. This causes errors like:

error returned from database: relation "yahoo.exchanges" does not exist

The Fix

The name() method now splits the table name on . and quotes each part separately, producing "yahoo"."exchanges" which PostgreSQL correctly interprets as schema + table.

Testing

  • Added a new migration and example in example-postgres that creates an app schema with a products table
  • The example demonstrates using #[ormx(table = "app.products", ...)]
  • Verified the example runs successfully against a local PostgreSQL database

Previously, a table name like `schema.table` would be quoted as
`"schema.table"`, which PostgreSQL interprets as a single identifier
containing a literal dot character.

This change splits the table name on `.` and quotes each part
separately, producing `"schema"."table"` which PostgreSQL correctly
interprets as schema + table.

This allows using schema-qualified table names in the `#[ormx(table = ...)]`
attribute, e.g.:

```rust
#[derive(ormx::Table)]
#[ormx(table = "my_schema.users", id = id)]
struct User { ... }
```

Added an example demonstrating schema-qualified table usage with `app.products`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant