File tree Expand file tree Collapse file tree 2 files changed +12
-13
lines changed Expand file tree Collapse file tree 2 files changed +12
-13
lines changed Original file line number Diff line number Diff line change @@ -1253,31 +1253,30 @@ public function getDefaultValueDeclarationSQL($field) : string
1253
1253
if (! isset ($ field ['default ' ])) {
1254
1254
return '' ;
1255
1255
}
1256
-
1257
- $ default = " DEFAULT ' " . $ field ['default ' ] . "' " ;
1258
- $ fieldType = $ field ['type ' ] ?? null ;
1256
+ $ defaultValue = $ this ->quoteStringLiteral ($ field ['default ' ]);
1257
+ $ fieldType = $ field ['type ' ] ?: null ;
1259
1258
if ($ fieldType !== null ) {
1260
- if (in_array ($ fieldType , [
1259
+ if ($ fieldType === DatableClickHouseType::TYPE_DATE ||
1260
+ $ fieldType instanceof DateType ||
1261
+ in_array ($ fieldType , [
1261
1262
'Integer ' ,
1262
1263
'SmallInt ' ,
1263
1264
'Float ' ,
1264
1265
]) ||
1265
1266
(
1266
1267
$ fieldType === 'BigInt '
1267
- && Type::getType ('BigInt ' )->getBindingType () === ParameterType::INTEGER )
1268
+ && Type::getType ('BigInt ' )->getBindingType () === ParameterType::INTEGER
1269
+ )
1268
1270
) {
1269
- $ default = ' DEFAULT ' . $ field ['default ' ];
1271
+ $ defaultValue = $ field ['default ' ];
1270
1272
} elseif ($ fieldType === DatableClickHouseType::TYPE_DATE_TIME &&
1271
1273
$ field ['default ' ] === $ this ->getCurrentTimestampSQL ()
1272
1274
) {
1273
- $ default = ' DEFAULT ' . $ this ->getCurrentTimestampSQL ();
1274
- } elseif (// TODO check if string matches constant date like 'dddd-yy-mm' and quote it
1275
- $ fieldType === DatableClickHouseType::TYPE_DATE ) {
1276
- $ default = ' DEFAULT ' . $ field ['default ' ];
1275
+ $ defaultValue = $ this ->getCurrentTimestampSQL ();
1277
1276
}
1278
1277
}
1279
1278
1280
- return $ default ;
1279
+ return sprintf ( ' DEFAULT %s ' , $ defaultValue ) ;
1281
1280
}
1282
1281
1283
1282
/**
Original file line number Diff line number Diff line change @@ -231,8 +231,8 @@ function ($row) {
231
231
public function fetchColumn ($ columnIndex = 0 )
232
232
{
233
233
$ elem = $ this ->fetch (FetchMode::NUMERIC );
234
- if (is_array ($ elem ) && array_key_exists ( $ columnIndex , $ elem ) ) {
235
- return $ elem [$ columnIndex ];
234
+ if (is_array ($ elem )) {
235
+ return $ elem [$ columnIndex ] ?? $ elem [ 0 ] ;
236
236
}
237
237
238
238
return false ;
You can’t perform that action at this time.
0 commit comments