If you want to have strict DB-constraints, you can:
db.define_table('barcode',
Field('code', type='string', unique=True, notnull=True), #
*consider
just 'code', not 'barcode'* - it's necessary to prevent possible
hard-to-catch bugs during SQLFORMs processing
i think it's can be done by record representation format, either in table
format or in requires validation format representation. (the
table bursary_entries just save the id for that refered to bursary_users,
but it will shown the barcode, if you set the format correctly either in
table format
Ah okay. It should only be done via. A validated form anyway but I see the
potential risk. Is the other option to set the barcode as the PK in my
bursary_users table and 'reference' it?
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (S
Keep in mind, that
'reference ' - realized at DB-level as FK-constraint, web2py allows to
define reference to PK only (you try to refer to not-PK field)
requires=... - just web2py validator and has no effect on underlying DB
and there isn't an autovalidation of DB manipulation from code
Okay, that seems to work fine, I guess I just tried to implement into
incorrectly. Thanks for your help!
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
How can I make the 'barcode' field in bursary_entries reference/depend upon
a 'barcode' entry in bursary_users? Do I just have to alter my field to:
type='text', requires=IS_IN_DB(db,'bursary_users.barcode)
I was trying to make sense of what was needed here and I thought 'requires'
was the best
'reference bursary_users' and requires = [IS_IN_DB(db, 'bursary_users
.barcode')] - I think, that it's mutually exclusive requirements
'reference bursary_users' == requires = IS_IN_DB(db, 'bursary_users.*id*')
On Friday, October 14, 2016 at 6:21:38 PM UTC+3, James Booth wrote:
>
> Hey gu
7 matches
Mail list logo