Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
DBUtils add_field bug
sdjones
December 2013
Hi,
When trying to add a field of data type bit via a migration script with a default I receive an error similar to following:
"incorrect default for field"
This is because Fuel decided to put the default value in quotes, so you end up with something similar to (from memory):
ALTER TABLE 'table_name' ADD field BIT DEFAULT '1'
This statement fails due to the quotes around the default value.
I have tried the following to no avail:
\DBUtil::add_fields('users', array(
'surname' => array('constraint' => 1, 'type' => 'bit', 'default' => 1)
));
\DBUtil::add_fields('users', array(
'surname' => array('constraint' => 1, 'type' => 'bit', 'default' => (int) 1)
));
Any thought or ideas? or is this actually a bug?
Harro
December 2013
Accepted Answer
Can you create an issue for this at
https://github.com/fuel/core/issues
?
You can work around it using
\DBUtil::add_fields('users', array(
'surname' => array('constraint' => 1, 'type' => 'bit', 'default' => \DB::expr(1))
));
which will prevent escaping the value.
sdjones
December 2013
thanks for the work around - i simply ran an sql statement after field add to default it. yours is more elegant though. issue created
Harro
December 2013
Thanks. Someone will look into it soon.
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,088
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
260
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
Harro
December 2013
sdjones
December 2013