[web-devel] Yesod, Sqlite, Enabling Foreign Key Support

Michael Snoyman michael at snoyman.com
Wed Apr 27 11:46:57 CEST 2011


The second argument is the list of replacements for question marks.
Passing in an empty list is the correct thing to do here.

Can you clarify what you mean by not working? Is it a compile time
error, a runtime exception, or everything goes along just fine but
foreign keys are not really enabled?

Michael

On Wed, Apr 27, 2011 at 12:38 PM, Anton Cheshkov <acheshkov at gmail.com> wrote:
> I trying this
> helperSqliteForeignON :: MonadIO m => SqlPersist m ()
> helperSqliteForeignON = execute "PRAGMA foreign_keys = ON" []
> -- How to run database actions.
> instance YesodPersist Pomoguy where
>     type YesodDB Pomoguy = SqlPersist
>     runDB db = liftIOHandler
>              $ fmap connPool getYesod >>= Settings.runConnectionPool
> (helperSqliteForeignON >> db)
> But it does not work. I do not understand why
> What is the second argument for 'execute' function ?
> Thanks.
> 2011/4/27 Michael Snoyman <michael at snoyman.com>
>>
>> Looks like the docs just got generated, at least for persistent.
>> You'll likely want the execute function from
>> Data.Persist.GenericSql.Raw:
>>
>> http://hackage.haskell.org/packages/archive/persistent/0.5.0/doc/html/Database-Persist-GenericSql-Raw.html
>> .
>>
>> Michael
>>
>> On Wed, Apr 27, 2011 at 9:12 AM, Anton Cheshkov <acheshkov at gmail.com>
>> wrote:
>> > I think helper function is good variant. I wanted to make it on yesod
>> > level
>> > but i do not see hackage documentation for newly packages.
>> > When documentation will  refreshed  i can try to make 'foreign enabling'
>> > on
>> > framework level ;)
>> > Thanks.
>> >
>> > 2011/4/27 Michael Snoyman <michael at snoyman.com>
>> >>
>> >> I'm not sure we want to enable this by default. What about just
>> >> providing a helper function that enables the pragma? There's already
>> >> enough available from the public API to execute arbitrary SQL
>> >> statements. I don't use SQLite for production deployments personally,
>> >> so if others have an opinion on this, I'd like to hear it.
>> >>
>> >> Michael
>> >>
>> >> On Tue, Apr 26, 2011 at 1:31 PM, Anton Cheshkov <acheshkov at gmail.com>
>> >> wrote:
>> >> > Hi Michael.
>> >> > Please show the way to enable foreign key support from sqlite
>> >> > connection.
>> >> > Now foreign key constrints does not work for sqlite from Yesod.
>> >> > Thanks.
>> >> >
>> >> > http://www.sqlite.org/foreignkeys.html
>> >> > --
>> >> > Best regards,
>> >> > Cheshkov Anton
>> >> > Phone: +7 909 005 18 82
>> >> > Skype: cheshkov_anton
>> >> >
>> >
>> >
>> >
>> > --
>> > Best regards,
>> > Cheshkov Anton
>> > Phone: +7 909 005 18 82
>> > Skype: cheshkov_anton
>> >
>
>
>
> --
> Best regards,
> Cheshkov Anton
> Phone: +7 909 005 18 82
> Skype: cheshkov_anton
>



More information about the web-devel mailing list