beneroth changed the topic of #picolisp to: PicoLisp language | The scalpel of software development | Channel Log: https://libera.irclog.whitequark.org/picolisp | Check www.picolisp.com for more information
seninha has quit [Ping timeout: 240 seconds]
isaneran has joined #picolisp
rob_w has joined #picolisp
pablo_escoberg has joined #picolisp
<pablo_escoberg> I'm having some issues understanding the db:
<pablo_escoberg> entities: (request '(+User) 'eml "user1@eml.com" 'pw "asdf" 'salt "aa" 'addr "user1 address" 'nm "user1")
<pablo_escoberg> -> {13}
<pablo_escoberg> entities: (db 'nm '+User "user1")
<pablo_escoberg> -> NIL
<pablo_escoberg> why is `db` not finding this record?
<pablo_escoberg> in fact, I can't get `db` or `collect` to return anything other than NIL and I can't for the life of me figure out what I'm doing wrong.
<abu[7]> Is the index correctly built? (scan (tree 'nm '+User))
<abu[7]> In any case, you pass too many args to 'request'
<pablo_escoberg> that returns NIL
<abu[7]> Should be only a proper combination of index trees
<abu[7]> i.e. a unique combination
<pablo_escoberg> yes, it is unique
<abu[7]> but the empty tree is another problem
<pablo_escoberg> right.  what's up with that?
<abu[7]> did you 'commit'?
<pablo_escoberg> yes
<pablo_escoberg> and when I view the DB file, I can see the data
<abu[7]> so the index is wrong
<abu[7]> maybe your E/R model?
<pablo_escoberg> Not sure how to trouble shoot this.
<pablo_escoberg> Is there some way to list all the records in the DB of a particular class?
<abu[7]> In the standard release, nm of +User is a +Key
<pablo_escoberg> or rather symbol?
<abu[7]> So this makes sense only *alone*
<abu[7]> (select +User)
<abu[7]> But without index it won't work
<abu[7]> same as 'collect'
<pablo_escoberg> that works!
<pablo_escoberg> and the correct record shows up on the list.
<abu[7]> How is the 'rel' for 'nm'?
<abu[7]> Standard is (rel nm (+Need +Key +String))
<pablo_escoberg> here's the entire entity:
<pablo_escoberg> (class +User +Rest +Entity)
<pablo_escoberg>   (rel id (+Key +Number) '111)
<pablo_escoberg>   (rel eml (+Key +Email +Frm +New) '210)
<pablo_escoberg>   (rel pw (+Key +Password +Frm +New) '200)
<pablo_escoberg>   (rel salt (+String) '000)
<pablo_escoberg>   (rel addr (+Idx +String +Frm +New) '210)
<pablo_escoberg>   (rel nm (+String +Frm +New) '210)
<pablo_escoberg>   (rel itins (+List +Joint +Frm) cust (+Itinerary) '210)
z4k4ri4_ has quit [Ping timeout: 255 seconds]
<abu[7]> 'nm' won't work
<pablo_escoberg> it has to have the +Key class?
<abu[7]> +String is the main class
z4k4ri4_ has joined #picolisp
<abu[7]> e.g. (rel nm (+Need +Key +String))
<pablo_escoberg> ok, TY.
<abu[7]> +Key is a *prefix*
<abu[7]> The order of the classes is important
<pablo_escoberg> oh, interesting.  +Key overrides methods in +String?
<abu[7]> Perhaps not in this case, but inheritance may not be passed on from main class to a prefix
<abu[7]> (vi 'rel> '+Key)
<abu[7]> it does (vi 'rel> '+Key)
<abu[7]> oops
<abu[7]> (extra Obj Old New Hook)
<pablo_escoberg> ok, I'll bear that in mind.  I had initially thought the various prefix classes wouldn't override each other, but I guess they'll have to in some cases.  I'll be on the lookout for that kind of thing.
<abu[7]> yeah, a prefix *knows* that it is a prefix
<abu[7]> Each class controls whether it calls 'extra' or `super' or both
<pablo_escoberg> ah, got it.  still not working, but at least I know what to play with...
<abu[7]> Better start with a simpler model first
<abu[7]> and then gradually extend it
<abu[7]> e.g. the standard +User
<abu[7]> @lib/adm.l
<abu[7]> I include lib/adm.l in every projevt
<abu[7]> *project
<abu[7]> You tend te write complicated stuff before understanding the mechanics ;)
<abu[7]> Lisp programming is incremental
<abu[7]> in the REPL
<pablo_escoberg> I did start pretty simple, had it working, and then went and did some JS stuff, came back and it no longer works.
<abu[7]> ok
<pablo_escoberg> but I'm not using the GUI, and am using marker classes and the like, so it looks more complicated than it is.
<abu[7]> The model I mean
<pablo_escoberg> well, that is about as simple as it gets...
<abu[7]> Lots of strange things
<abu[7]> (rel salt (+String) '000)
<abu[7]> what is '000 ?
<pablo_escoberg> permissions.
<pablo_escoberg> (redef rel Lst
<pablo_escoberg>   (if (and (num? (cdar (tail 1 Lst))) (not (num? (tail 1 Lst))))
<pablo_escoberg>     (prog (eval (cons 'rel (head -1 Lst) ))
<pablo_escoberg>       (perms> (get *Class (car Lst)) (car (tail 1 Lst))))
<pablo_escoberg>     (eval (cons 'rel Lst))))
<pablo_escoberg> that's how I did that.
<abu[7]> '+String' does not expect such an argumeny
<abu[7]> t
<pablo_escoberg> all 'rels' do with that code in there...
<abu[7]> '000 is ignored
<pablo_escoberg> (extend +relation)
<pablo_escoberg>   (dm perms> (p)
<abu[7]> besides that it is simply zere
<pablo_escoberg>     (if p (=: perms p) (: perms)))
<pablo_escoberg> oops, forgot about that
<abu[7]> '0
<abu[7]> no need to quote
<abu[7]> Anyway it is ignored by +String
<pablo_escoberg> and yes, that happens, but for the sake of consistency with other permissions, I put it that way.
<pablo_escoberg> I extend the `+relation` class above so it doesn't.
<abu[7]> and 'rel' does not evaluate
<abu[7]> so the quote remains in the data
<pablo_escoberg> it all works as intended
<abu[7]> Never
<abu[7]> unless you modified the +String class
<pablo_escoberg> IOW, I can retrieve the permissions from the relations.
<pablo_escoberg> If it interferes with retrieving data, I'll have to look into it, but it does store it.
<pablo_escoberg> I modified the +String class by extending the +relation class.
<pablo_escoberg> +String inherits from +relation
<abu[7]> ok
<abu[7]> Then I cannot help
<pablo_escoberg> Cool, thanks.
msavoritias has joined #picolisp
<pablo_escoberg> OK, so I took out all the custom stuff.  It now looks like this:
<pablo_escoberg> (class +User +Rest +Entity)
<pablo_escoberg>   (rel id (+Key +Number))
<pablo_escoberg>   (rel eml (+Key +Email))
<pablo_escoberg>   (rel pw (+Key +Password))
<pablo_escoberg>   (rel salt (+String))
<pablo_escoberg>   (rel addr (+Idx +String))
<pablo_escoberg>   (rel nm (+Key +String))
<pablo_escoberg>   (rel itins (+List +Joint +Frm) cust (+Itinerary))
<pablo_escoberg> And the same thing happens.
<pablo_escoberg> entities: (db 'nm '+User )
<pablo_escoberg> -> NIL
<pablo_escoberg> even though `select` shows the expected records.
<abu[7]> Model looks good I think
<abu[7]> (collect 'nm '+User) ?
<abu[7]> or (scan (tree 'nm '+User))
<abu[7]> (+List +Joint +Frm) is still unusual, depends on what you modified in the relation classes
<abu[7]> 'select' does some heuristics to look for indexes
<abu[7]> Better do "hard" investigations with 'scan' etc
<abu[7]> or at least (select +User nm "foo") to force an index
<pablo_escoberg> yeah, 'scan' yields NIL
<abu[7]> Did you remove the old db?
<abu[7]> before creating stuff in the new model?
<pablo_escoberg> just did that, same thing.
<abu[7]> Then perhaps a min call
<abu[7]> (new '(+User) 'nm "foo")
<pablo_escoberg> also removed all my customizations for the +relation class, etc.
<abu[7]> then scan
<abu[7]> oops
<abu[7]> (new! '(+User) 'nm "foo")
<pablo_escoberg> entities: (new! '(+User) 'nm "foo")
<pablo_escoberg> -> {10}
<pablo_escoberg> entities: (scan (tree 'nm '+User))
<pablo_escoberg> -> NIL
<abu[7]> Sorry, must hurry for the train
<pablo_escoberg> ok, TY.  We'll figure it out a different time.  have a good trip.
<abu[7]> Thanks! I can continue later in the train.
<abu[7]> On rails :)
<pablo_escoberg> well, you are certainly hard care!
<pablo_escoberg> core*
<abu[7]> :)
<pablo_escoberg> BTW, looks like I figured it out, more or less.  the issue was not in the relations, but in the entity.  my +Rest class seems to have interfered; I'll need to put it last.
<abu[7]> great
pablo_escoberg has quit [Quit: Client closed]
msavoritias has quit [Read error: Connection reset by peer]
seninha has joined #picolisp
inara has quit [Ping timeout: 255 seconds]
inara has joined #picolisp
isaneran has quit [Ping timeout: 260 seconds]
Cycloner has joined #picolisp
Cycloner has quit [Remote host closed the connection]
z4k4ri4_ has quit [Ping timeout: 246 seconds]
z4k4ri4_ has joined #picolisp
rob_w has quit [Quit: Leaving]
isaneran has joined #picolisp
isaneran has quit [Ping timeout: 260 seconds]
Little_Shener has joined #picolisp
Little_Shener is now known as little_shener
little_shener is now known as small_shener
seninha has quit [Ping timeout: 258 seconds]
small_shener is now known as print_bad
print_bad is now known as cycloren
cycloren has quit [Remote host closed the connection]
Little_Shener has joined #picolisp
Little_Shener has quit [Remote host closed the connection]
seninha has joined #picolisp
pablo_escoberg has joined #picolisp
Cycloner has joined #picolisp
Cycloner has quit [Remote host closed the connection]