Smart-joins helper needs peer review :)

38 views
Skip to first unread message

Jurgis Pralgauskis

unread,
Nov 27, 2016, 5:01:53 PM11/27/16
to web...@googlegroups.com
Hi,

Web2py is nice for its expression brevity -- but  joins still need quite long texting..
I wanted to make it simpler, because "readability counts" :)

now you can write

build_joins( ['auth_user', 'auth_membership', 'auth_group', 'auth_permission'] )

instead of

[
  db.auth_membership.on( db.auth_membership.user_id == db.auth_user.id ),
  db.auth_group.on( db.auth_group.id == db.auth_membership.group_id ),
  db.auth_permission.on( db.auth_permission.group_id == db.auth_group.id ),
]

Helper uses DB model to figure out the needed fields for join'ing
(if it finds more than one possible field -- would throw an error with explatnation)

Alpha version
https://github.com/dz0/web2py_grand_helpers/blob/master/joins_builder.py

Sugestions/patches welcome :)

Marlysson Silva

unread,
Nov 28, 2016, 10:11:09 AM11/28/16
to web2py-users
The great job .. I am just looking in your project awesome.. Now I go studying more framework to help you in your project :D


Em domingo, 27 de novembro de 2016 19:01:53 UTC-3, Jurgis Pralgauskis escreveu:
Hi,

Web2py is nice for its expression brevity -- but  joins still need quite long texting..
I wanted to make it simpler, because "readability counts" :)

now you can write

build_joins( ['auth_user', 'auth_membership', 'auth_group', 'auth_permission'] )

instead of

[
  db.auth_membership.on( db.auth_membership.user_id == db.auth_user.id ) ),
  db.auth_group.on( db.auth_group.id == db.auth_membership.group_id ) ),
  db.auth_permission.on( db.auth_permission.group_id == db.auth_group.id ) ),
]

Helper can use DB model to figure out the needed fields for join'ing
Reply all
Reply to author
Forward
0 new messages