<div dir="ltr">Hi Manuel,<div><br></div><div>I'm currently in the same position as you are, except I'm not using Yesod.</div><div><br></div><div>I've spent some time trying to migrate our current DB setup to use persistent.</div>
<div>It's not really built to handle existing schemas. There's no inherent mismatch here, it just needs to be implemented.</div><div><br></div><div>The main things I've found are missing:</div><div>* The ability to declare foreign relations across different QQ blocks and verifying them with migrations.</div>
<div>* There is no support for non-int primary keys (support for omitting a pk for join tables was recently merged, but I need support for other types of primary keys on normal tables, such as postgres uuid).</div><div>* It's not possible to define foreign keys on uniqueness constraints. I might not care about this anymore because of the join table patch I mentioned above.</div>
<div>* It's not flexible in column types, Text maps to character varying (but not text), and serial to int8. This isn't wrong but you cannot use aliases for these types. This should be fairly straight forward to fix I think.<br>
</div><div><br></div><div>I also think persistent is too backend agnostic :) I only really care about postgres, and I think it would simplify a lot of things if there was a library built only for it.</div><div><br></div><div>
So unless you are willing to modify your schemas or patch persistent it doesn't seem to be a viable alternative. The good news is that Michael and Greg are very helpful and I'm sure they'd happily accept these changes, and esqueleto is a very nice EDSL.</div>
<div><br></div><div>I have the same impression of HaskellDB as you have, but I haven't tested using it yet.</div><div>I also need joins so groundhog is currently off the table too.</div><div>Tom's library seems interesting but I haven't had the chance to try it out yet.<br>
</div><div><br></div><div>I'm currently using HDBC which is middleware like the -simple packages, but without the static guarantees you mention maintenance has become a pain.</div><div><br></div><div>We haven't decided how to proceed on this, but I'll try to write a summary once we have something up and running. Please let me know if you find a good solution too!</div>
<div><br></div><div>- Adam</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Nov 20, 2013 at 7:44 PM, Boris Lykah <span dir="ltr"><<a href="mailto:lykahb@gmail.com" target="_blank">lykahb@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br>
<br>
As the author of Groundhog library I agree that it and<br>
Persistent/Esqueleto have strengths in different areas and none of<br>
them fully matches power of SQL. Grounhog has better support of SQL<br>
expressions and relational schemas (composite keys, schemas, indexes,<br>
etc.) Persistent cannot do a query with projections and nested<br>
function calls like:<br>
<br>
project (upper (FirstNameField `append` SecondNameField), toArith<br>
BalanceField * 10) $ lower UserNameField `like` "%smith%"<br>
<br>
On the other hand, while Groundhog can query only one table at a time,<br>
Persistent combined with Esqueleto gives relational query capabilities<br>
that match a lot of the SQL syntax (notably excluding column<br>
aliasing).<br>
<br>
I like Esqueleto and it seems to be easy to port to Groundhog. The<br>
ported codebase may be even smaller because Groundhog already has<br>
flexible functions and comparison operators which uniformly support<br>
fields and constant values. Alas, I don't have enough time to do<br>
this. If someone is interested in porting I will be happy to help.<br>
<br>
Thanks,<br>
Boris<br>
<div class="HOEnZb"><div class="h5"><br>
On Wed, Nov 20, 2013 at 12:11 AM, Manuel Gómez <<a href="mailto:targen@gmail.com">targen@gmail.com</a>> wrote:<br>
> On Tue, Nov 19, 2013 at 11:20 PM, Erik de Castro Lopo<br>
> <<a href="mailto:mle%2Bhs@mega-nerd.com">mle+hs@mega-nerd.com</a>> wrote:<br>
>> Manuel Gómez wrote:<br>
>>> * Persistent: it’s perfectly integrated into Yesod, and together<br>
>>> with Esqueleto, it provides a nice, typesafe and fully expressive EDSL<br>
>>> — but, as far as I can tell, there is no support for specifying schema<br>
>>> names, which is essential for my use case.<br>
>><br>
>> I'm not sure of what you mean here. DO you mean that you already have<br>
>> a database and schema and you now want to connect Persisent/Esqueleto<br>
>> to it without changing the existing schema?<br>
><br>
> Hi Erik,<br>
><br>
> Indeed, that’s more or less the situation I’m facing. Perhaps the<br>
> overloading of the term “schema” is a problem here: what I<br>
> specifically meant with this point is the namespacing mechanism<br>
> present in (some implementations of) SQL databases: database object<br>
> names are bound within namespaces called schemas, and a name can be<br>
> qualified with the name of the schema, separated by a dot; hence a<br>
> table named `"with spaces"` in a schema/namespace called `"some<br>
> tables"` would be used qualified as `"some tables"."with spaces"`.<br>
><br>
> I have an existing schema (read: database) with many schemas (read:<br>
> namespaces) and I need to do joins between tables in them. The names<br>
> have spaces and unusual bits of Unicode, and the dot that separates<br>
> the schema name from the object name mustn’t be quoted, so it’s not<br>
> simply a matter of specifying a complex name to Persistent, as<br>
> escaping and quoting wouldn’t be done correctly. A workaround could<br>
> be to put everything in a single namespace and use prefixes in names,<br>
> but that causes other issues for me (other tools would break).<br>
><br>
> The other issue I have with Persistent+Esqueleto is that the database<br>
> I have to work with has some composite or otherwise non–serial-integer<br>
> primary keys, and I understand Persistent requires a serial primary<br>
> key. I could probably work around this, though.<br>
> _______________________________________________<br>
> Haskell-Cafe mailing list<br>
> <a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
> <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br>
<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
Regards,<br>
Boris<br>
</font></span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br></div>