-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
a bug of db class #1695
Comments
AUTO_INCREMENT won't work with For --- a/ext/db/dialect/mysql.c
+++ b/ext/db/dialect/mysql.c
@@ -247,16 +247,14 @@ PHP_METHOD(Phalcon_Db_Dialect_Mysql, addColumn){
PHP_METHOD(Phalcon_Db_Dialect_Mysql, modifyColumn){
zval *table_name, *schema_name, *column, *sql = NULL, *name;
- zval *column_definition, *is_not_null;
+ zval *column_definition, *is_not_null, *is_autoincrement;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 3, 0, &table_name, &schema_name, &column);
- if (Z_TYPE_P(column) != IS_OBJECT) {
- PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Column parameter must be an instance of Phalcon\\Db\\Column");
- return;
- }
+ PHALCON_VERIFY_INTERFACE_EX(column, phalcon_db_columninterface_ce, phalcon_db_exception_ce, 1);
+
if (zend_is_true(schema_name)) {
PHALCON_INIT_VAR(sql);
PHALCON_CONCAT_SVSVS(sql, "ALTER TABLE `", schema_name, "`.`", table_name, "` MODIFY ");
@@ -278,6 +276,13 @@ PHP_METHOD(Phalcon_Db_Dialect_Mysql, modifyColumn){
phalcon_concat_self_str(&sql, SL(" NOT NULL") TSRMLS_CC);
}
+ PHALCON_INIT_VAR(is_autoincrement);
+ phalcon_call_method(is_autoincrement, column, "isautoincrement");
+
+ if (zend_is_true(is_autoincrement)) {
+ phalcon_concat_self_str(&sql, SL(" AUTO_INCREMENT") TSRMLS_CC);
+ }
+
RETURN_CTOR(sql);
}
|
Please check now. |
ok thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The method modifyColumn of database class will lost the AUTO_INCREMENT attribute of fields.
Because modifyColumn method does not determine whether the field contains AUTO_INCREMENT attribute.
the same bug is also at addColumn method ,which means you can not add a column that contains the attribute AUTO_INCREMENT
数据库类的modifyColumn方法会丢失字段的AUTO_INCREMENT属性;因为modifyColumn方法没有判断字段是否包含AUTO_INCREMENT属性。
addColumn 包含同样的问题,即无法添加AUTO_INCREMENT字段。
The text was updated successfully, but these errors were encountered: