valderman / selda

A type-safe, high-level SQL library for Haskell
https://selda.link
MIT License
478 stars 58 forks source link

Cross-schema queries #125

Open danstn opened 5 years ago

danstn commented 5 years ago

...or schema definition on Table level.

Is there a way to define a cross-schema queries in postgresql?

e.g.

SELECT x.a, y.b FROM s1.x JOIN s2.y ON (..)

Assessing Selda as a core lib for an existing (quite large) postgresql access.

The only way right now is via PGConnectInfo it seems.

valderman commented 5 years ago

Right now, there is no way to do this. However, it looks like adding support for it would be almost trivial, possibly with the exception of migrations.

danstn commented 4 years ago

Personally don't care about migrations :)

Do you think it's realistic to introduce it anytime soon @valderman? We're currently on opaleye and table defs get quite nasty with all that profunctor business going on there.

Would love to take Selda for a spin if it had multi-schema support for statements.

valderman commented 4 years ago

We could absolutely get this in by the next release but, as you may have noticed, I'll be very short on time for Selda work for the next three months so I'm afraid the next release will still be a while.

I'd be happy to merge support for this if anyone else wants to do it in the meantime. It should be a relatively straightforward matter of adding a new tableWithSchema (or similar) function, an optional schema field to the Table type, and slightly alter the table name compilation functions. For SQLite, we could probably get away with just treating the schema as a prefix to the name or something.