artanis
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MySQL/MariaDB Boolean Type


From: Nala Ginrut
Subject: Re: MySQL/MariaDB Boolean Type
Date: Mon, 13 Mar 2023 20:40:41 +0800
User-agent: mu4e 1.4.15; emacs 27.1

Hi Jaft!
I found the boolean is missing in MySQL type converter somehow, I've
fixed in the latest commit.
BTW, I think you should use "TRUE" or "FALSE" rather than #t or #f,
since I don't rememmber if I made any conversion for you. IMO, it's
bette not do any inexplicit conversion for users.

Please try it again.

Best regards.


Jaft writes:

>  I'd been using commit e50772d19322a27425f85485c38306c8b093d72d, as I thought 
> it should be current-enough, but, to be certain, I've just changed to the 
> latest commit (a6a6e79b19533e1de31a31ef680ae1a1b969826a). When trying to run 
> the migration
>
> (migrate-create (create-table 'REVISED_WORDS
>                               '(REVISED_WORD_ID  auto       (#:primary-key))
>                               '(REVISED_WORD     char-field (#:not-null    
> #:unique #:maxlen  200))
>                               '(NEW_SPELLING     char-field (#:not-null    
> #:unique #:maxlen  200))
>                               '(TAKES_PRECEDENCE boolean    (#:not-null       
>       #:default #t))
>                               '(NOTES            text       (#:not-null       
>       #:default ""))))
> Artanis throws, when I run art migrate create REVISED_WORDS, the error
>
> Creating table `REVISED_WORDS'......Backtrace:
> In ice-9/boot-9.scm:
>   1752:10 12 (with-exception-handler _ _ #:unwind? _ # _)
> In unknown file:
>           11 (apply-smob/0 #<thunk 7f4dd30af540>)
> In ice-9/boot-9.scm:
>     724:2 10 (call-with-prompt _ _ #<procedure default-prompt-handle…>)
> In ice-9/eval.scm:
>     619:8  9 (_ #(#(#<directory (guile-user) 7f4dd30b2c80>)))
> In 
> /gnu/store/6vzx5d827di2h7mfcvmc3wwk8j4iia1s-artanis-latest-0.5.1-3.a6a6e79/bin/.art-real:
>     42:12  8 (_ _ _)
> In artanis/mvc/migration.scm:
>      95:4  7 (create-table REVISED_WORDS . _)
> In artanis/fprm.scm:
>    411:18  6 (_ REVISED_WORDS ((REVISED_WORD_ID serial (# # #)) # …) …)
> In ice-9/boot-9.scm:
>    222:29  5 (map1 ((REVISED_WORD_ID serial (#:no-edit # #)) (# …) …))
>    222:29  4 (map1 ((REVISED_WORD varchar 200 (#:not-null #)) (# …) …))
>    222:29  3 (map1 ((NEW_SPELLING varchar 200 (#:not-null #)) (# …) …))
>    222:17  2 (map1 ((TAKES_PRECEDENCE boolean (#:not-null # #t)) (…)))
> In artanis/fprm.scm:
>    401:49  1 (->types _)
>    153:10  0 (->mysql-type _ . _)
>
> artanis/fprm.scm:153:10: In procedure ->mysql-type:
> Throw to key `artanis-err' with args `(500 #<procedure ->mysql-type (name . 
> args)> "Invalid type name `~a'" boolean)'.
>
> I figured the error would still be present in the most recent work as, when I 
> checked the ->mysql-type function earlier, I'd just looked at the GitLab 
> master branch. Am I assuming the wrong location for vanilla? I figured you 
> meant "latest master" but I could be mistaken.
> Hopefully, I've explained the steps I'm taking clearly but I don't always so 
> let me know, please, if anything I've said so far doesn't make sense and I'll 
> try my best to clarify.
>     On Sunday, March 12, 2023 at 12:23:27 PM CDT, Nala Ginrut <mulei@gnu.org> 
> wrote:
>
>
> Hi Jaft!
> I actually fixed several bugs in models and migrations in recent
> months. Maybe you should try vanilla now.
>
> Best regards.
>
>
> Jaft writes:
>
>>  Mmm; then maybe there's an issue just with migrations? When I tried using 
>> "boolean" for creating a table in a migration, I got an error in 
>> "->mysql-type"; checking that function out, I did notice that there's no 
>> case for "boolean".
>>    On Friday, March 10, 2023 at 01:07:48 PM CST, Nala Ginrut <mulei@gnu.org> 
>> wrote:
>>
>>
>> Sorry, I misunderstood you.
>> You were asking why I provide it.
>> Actually, for mysql/mariadb, Artanis won't do anything for boolean, it's
>> only for sqlite3. So it won't cause any problem.
>>
>> Best regards.
>>
>>
>> Nala Ginrut writes:
>>
>>> Hi Jaft!
>>> Aratnis had abstracted boolean type in mvc/model.scm
>>> --------------------code----------------
>>> (define *db-specific-types*
>>> '((mysql
>>> (text . longtext)
>>> (boolean . boolean))
>>> (postgresql
>>> (text . text)
>>> (boolean . boolean))
>>> (sqlite3
>>> (text . text)
>>> (boolean . integer))))
>>> ---------------------end-----------------
>>>
>>>
>>>
>>> You may use `boolean' to define a table in a model, for example:
>>>
>>> -----------------code---------------
>>> (create-table
>>> 'user
>>> '(id auto (#:primary-key))
>>> '(name char-field (#:not-null #:maxlen 128))
>>> '(is_admin boolean (#:not-null))
>>> '(last_login bigint (#:unsigned #:not-null)))
>>> ------------------end------------------
>>>
>>> I'm sorry I haven't put it in the document, I'll introduce it in the
>>> recent release.
>>>
>>> Best regards.
>>>
>>>
>>>
>>> Jaft writes:
>>>
>>>> I think I always meant to ask but keep forgetting to – what wouldyou 
>>>> think, Nala, of providing a boolean type?
>>>> Both MySQL and MariaDB abstract this type for the user, already, so 
>>>> doingthe same at the Artanis layer wouldn't be terribly different than the 
>>>> DB converting boolean values to 1 and 0, right?
>>>> And it'd make working with those values easier to read when reading the 
>>>> code of a project, for the first time.


--
GNU Powered it
GPL Protected it
GOD Blessed it
HFG - NalaGinrut
Fingerprint F53B 4C56 95B5 E4D5 6093 4324 8469 6772 846A 0058

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]