In web2py, can an existing named field be specified as an auto-dialer identifier in an obsolete database?

I have dozens of tables in an existing MSSQL database, all with autonumber ID primary keys, but none of them are named 'id'. They are instead of the name PropertyID, ClientID, etc. The official documentation seems to suggest renaming each of these fields to 'id':

Deprecated Databases

web2py may connect to legacy databases under certain conditions:

  • Each table must have a unique auto-increment integer field called "id"
  • Entries must be specified exclusively using the "id" field.

If these conditions are not met, it is necessary to manually press ALTER TABLE to comply with these requirements or they cannot be accessed via web2py.

This should not be construed as limiting, but rather as one of many ways web2py encourages you to follow good practice.

However, this will require hacking into hundreds of existing queries in other applications that use this database. Of course, there must be some way to specify a name for the existing autonumber field, which will be used instead of 'Identifier'.

This seems to be the area where Django got it right and web2py got it terribly wrong . Or am I just missing something? It seems I just missed something ...

+3
source share
2 answers

This statement is outdated. Web2py supports three cases:

  • , "id" ( )
  • , "id",

    db.define_table('name',Field('id_name','id'),...other fields...)

  • db.define_table('name',...fields..., primarykey=[....])

- .

3 , . , . web2py, .

+4

-, web2py, , . google2 web2py: web2py .

NOTE. I found this by looking at New Features Not Documented in a PDF Book (2 ed)

+1
source

Source: https://habr.com/ru/post/1754262/


All Articles