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

Anton Cheshkov acheshkov at gmail.com
Wed Apr 27 07:08:47 CEST 2011


I do not understand what have happened . But today all works ;)
*
*
*res <- runDB $ E.catch (insertBy offer) (\(e :: E.SomeException) -> return
$ Left undefined)*
*
*
But sometimes i see in console follow:
*
*
*Attempting to interpret your app...*
*wai-handler-devel: user error (SQLite3 returned ErrorBusy while attempting
to perform close: unable to close due to unfinalised statements)*
*
*


2011/4/26 Anton Cheshkov <acheshkov at gmail.com>

> I can not catch exception
> *user error (SQLite3 returned ErrorConstraint while attempting to perform
> step.*)
> *
> *
> I do it as:
> *res <- runDB $ E.catch (insertBy offer) (\(e :: E.SomeException) ->
> return $ Left undefined)
> *
>
> 2011/4/26 Anton Cheshkov <acheshkov at gmail.com>
>
>> Ok.
>>
>> I recompiled persistent with new changes. All works how i want and expect.
>> But now   *insertBy* function are not so safe as earlier.
>>
>> *The insertBy function* checks only unique constrains defined on yesod
>> framework level via Unique... constructions  .
>> Now  *insertBy* function throws exception if we try to insert 'bad' value
>> to column with foreign constraint.
>>
>> Please show me how to catch exception.
>> I think it would something like:
>> *
>> *
>> *import qualified Control.Exception.Control as E*
>> *...*
>> *do*
>> *   res <- runDB $ E.catch (insertBy offer) (\_ -> return Left ())*
>>
>> But my exception handler is wrong.
>>
>>
>> Thanks.
>>
>> 2011/4/26 Greg Weber <greg at gregweber.info>
>>
>>> Thanks!
>>>
>>> Please send a pull request to Michael.
>>>
>>> On Tue, Apr 26, 2011 at 5:58 AM, Anton Cheshkov <acheshkov at gmail.com>wrote:
>>>
>>>> I have pushed branch to fix it. probably it should be helpful.
>>>> https://github.com/acheshkov/persistent
>>>>
>>>> <https://github.com/acheshkov/persistent>Thanks.
>>>>
>>>>
>>>> 2011/4/26 Anton Cheshkov <acheshkov at gmail.com>
>>>>
>>>>> 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
>>>>
>>>> _______________________________________________
>>>> web-devel mailing list
>>>> web-devel at haskell.org
>>>> http://www.haskell.org/mailman/listinfo/web-devel
>>>>
>>>>
>>>
>>
>>
>> --
>> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/web-devel/attachments/20110427/5bea7207/attachment-0001.htm>


More information about the web-devel mailing list