Re: [web2py] Re: Db fields in the "links" of the grid

2020-10-08 Thread Jim S
I looked back through my code and didn't find an instance where I had custom links on a grid with a left join. And, I've been coding in web2py since 2011. -Jim On Thursday, October 8, 2020 at 10:38:12 AM UTC-5, Vlad wrote: > > Jim, > > Thank you very much for your help, > > This is a perfect

Re: [web2py] Re: Db fields in the "links" of the grid

2020-10-08 Thread Eliezer (Vlad) Tseytkin
Jim, Thank you very much for your help, This is a perfect solution for me. It just took me time to figure out what was going on. I don't think that this can be classified as a bug in web2py. It's just very confusing for anybody who encounters this situation. However, if I am the only one who

Re: [web2py] Re: Db fields in the "links" of the grid

2020-10-08 Thread Jim S
Vlad The behavior is exactly as you said it is. I don't know if I'd go as far as saying this is a problem with web2py. I got around it by using this instead of the try/except in GetCartsGridLink id = row.cart.id if 'cart' in row else row.id I know it isn't ideal and isn't what you were

Re: [web2py] Re: Db fields in the "links" of the grid

2020-10-08 Thread Vlad
Just realized that there is another field, virtual one, referenced in the code. In case the problem doesn't reproduce without it, here is the definition (but I don't think that this would be necessary): db.cart.count = Field.Virtual(lambda row:

Re: [web2py] Re: Db fields in the "links" of the grid

2020-10-08 Thread Vlad
Sure, the sample data attached (are these 2 tables enough?), and the models are as follows: db.define_table('cart', Field('description','string',default='My Cart (%s)' % str((datetime.now().strftime("%m/%d/%Y %I:%M%p", auth.signature) db.define_table('cart_ownership',

Re: [web2py] Re: Db fields in the "links" of the grid

2020-10-08 Thread Jim S
any chance you have a model and a small sample-set of data you could share that cause the inconsistencies to be shown? Just 3 records or so in each table that can show the inconsistency? On Thursday, October 8, 2020 at 7:38:48 AM UTC-5, Vlad wrote: > > Yes, there is always a corresponding

Re: [web2py] Re: Db fields in the "links" of the grid

2020-10-08 Thread Eliezer (Vlad) Tseytkin
Yes, there is always a corresponding record in the second table (doesn't have to be, but I do clean up ownerless carts, so when I am testing things, the corresponding record is always there). Here is the complete creation of the grid (where GetCartsGridLink is the function that now has try/except

Re: [web2py] Re: Db fields in the "links" of the grid

2020-10-07 Thread Jim Steil
I will take a look tomorrow to see if I can code something up to reproduce the error. Which tackle are you setting as the 'primary' table, by that I mean what field are you specifying in the field_id parameter? And, is there ALWAYS a matching record in the secondary table? Oh, just thought of

Re: [web2py] Re: Db fields in the "links" of the grid

2020-10-07 Thread Eliezer (Vlad) Tseytkin
Jom, you said " I'm having trouble understanding why you need the try/except" - this is exactly the trouble I'm having too :) I do use the left join. So I should simply specify the table name - correct? Well, if I do - then the grid itself works fine, but once I click "view" or "edit" - it

Re: [web2py] Re: Db fields in the "links" of the grid

2020-10-07 Thread Jim S
I'm having trouble understanding why you need the try/except. To me it seems like "if you specify a left" -> you need to use the table name. "if you don't specify a left" -> omit the table name Do you have an occasion where sometimes different rows in the same grid require you to specify the

Re: [web2py] Re: Db fields in the "links" of the grid

2020-10-07 Thread Eliezer (Vlad) Tseytkin
But shouldn't it be the same for the grid and for the record of the grid? The difference confuses me - having to specify the table should be consistent when I use the grid for all the transactions of the grid, including view/edit etc.. In other words, having to specify the table is perfectly fine

Re: [web2py] Re: Db fields in the "links" of the grid

2020-10-07 Thread Jim Steil
I think that is a result of having a left join specified. With the left join you now have to specify which table the field is in as well. Or, am I missing something? -Jim On Wed, Oct 7, 2020 at 9:13 PM Eliezer (Vlad) Tseytkin < westgate6...@gmail.com> wrote: > Jim, > > Thank you for the

Re: [web2py] Re: Db fields in the "links" of the grid

2020-10-07 Thread Eliezer (Vlad) Tseytkin
Jim, Thank you for the suggestions. I do specify field_id (it wasn't there in the simplified code, but the complete code does have it). When I use a function, instead of the lambda, I indeed can have a solution, but at the same time it emphasizes that something is wrong: The links are now

[web2py] Re: Db fields in the "links" of the grid

2020-10-07 Thread Jim S
I have a couple of ideas, but none are tested First, can you try adding the field_id parameter to your SQLFORM.grid() call? I believe that tells this grid which is your 'primary' table. Secondly (this is the way I typically handle it) - instead of coding everything in a lambda, call a