Skip to content

Commit c4671ab

Browse files
committed
Fix for #568
1 parent 8b3b0a4 commit c4671ab

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

api.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4702,6 +4702,16 @@ public function __construct(string $driver)
47024702

47034703
public function convertColumnValue(ReflectedColumn $column): string
47044704
{
4705+
if ($column->isBoolean()) {
4706+
switch ($this->driver) {
4707+
case 'mysql':
4708+
return "IFNULL(IF(?,TRUE,FALSE),NULL)";
4709+
case 'pgsql':
4710+
return "?";
4711+
case 'sqlsrv':
4712+
return "?";
4713+
}
4714+
}
47054715
if ($column->isBinary()) {
47064716
switch ($this->driver) {
47074717
case 'mysql':
@@ -4734,7 +4744,6 @@ public function convertColumnName(ReflectedColumn $column, $value): string
47344744
return "encode($value::bytea, 'base64') as $value";
47354745
case 'sqlsrv':
47364746
return "CASE WHEN $value IS NULL THEN NULL ELSE (SELECT CAST($value as varbinary(max)) FOR XML PATH(''), BINARY BASE64) END as $value";
4737-
47384747
}
47394748
}
47404749
if ($column->isGeometry()) {

src/Tqdev/PhpCrudApi/Database/ColumnConverter.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ public function __construct(string $driver)
1515

1616
public function convertColumnValue(ReflectedColumn $column): string
1717
{
18+
if ($column->isBoolean()) {
19+
switch ($this->driver) {
20+
case 'mysql':
21+
return "IFNULL(IF(?,TRUE,FALSE),NULL)";
22+
case 'pgsql':
23+
return "?";
24+
case 'sqlsrv':
25+
return "?";
26+
}
27+
}
1828
if ($column->isBinary()) {
1929
switch ($this->driver) {
2030
case 'mysql':
@@ -47,7 +57,6 @@ public function convertColumnName(ReflectedColumn $column, $value): string
4757
return "encode($value::bytea, 'base64') as $value";
4858
case 'sqlsrv':
4959
return "CASE WHEN $value IS NULL THEN NULL ELSE (SELECT CAST($value as varbinary(max)) FOR XML PATH(''), BINARY BASE64) END as $value";
50-
5160
}
5261
}
5362
if ($column->isGeometry()) {

0 commit comments

Comments
 (0)