Ticket #841 (new defect)

Opened 13 months ago

Last modified 9 months ago

Codegen not creating [Collumn]Default constants properly

Reported by: joe Owned by:
Priority: important Milestone:
Component: Database adapter Version: 2.1.0 Stable
Keywords: Cc:

Description

Currently all database 'Gen' classes are being created with NULL defaults constants.

For example in our table, we have a column named UserName with a default of 'Guest'. In the TableNameGen class file, there is a constant being created named UserNameDefault being set to NULL. However, it should be set to 'Guest'.

I have a fix for MySqli adapter. Line 566 in QMySqliDatabase.class.php QMySqliDatabaseField::__construct(), add right after if ($objRow["Field"] == $this->strOriginalName) {

$this->strDefault = $objRow["Default"];

After adding this, we are able to use the constant TableName::UserNameDefault, and $objTableName->Initialize() works as expected.

I have to work on learning how to generate and upload a diff.

Attachments

QMySqliDatabase.class.php.patch Download (0.7 KB) - added by joe 13 months ago.

Change History

Changed 13 months ago by joe

Changed 13 months ago by joe

Other adapters seem to be affected too. But, since I don't run those database adapters, I cannot test them.

Changed 12 months ago by vaibhav

Thanks Joe for the wonderful work. It is working perfectly.

@Other Developers: I am unaware of how MySql is handled in QCubed so I am refraining myself from committing this patch. The patch submitted by Joe works perfectly though.

Changed 12 months ago by vaibhav

Also, I am using PostgreSQL and it is working all fine for me.

Changed 9 months ago by vaibhav

@other lead devs: If anyone has an experience with MySQL and has tested this patch, please tell me. I plan to commit it within a week as it seems to solve the problem on my end.

Regards,
Vaibhav

Note: See TracTickets for help on using tickets.