Skip to content

Commit

Permalink
decimal
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Aug 28, 2024
1 parent 18c8dbf commit 1d6103d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
3 changes: 0 additions & 3 deletions src/Database/Drivers/Engines/MySQLEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,6 @@ public function getForeignKeys(string $table): array
public function resolveColumnConverter(array $meta, TypeConverter $converter): ?\Closure
{
return match ($meta['nativeType']) {
'NEWDECIMAL' => $converter->convertDecimal
? ($meta['scale'] === 0 ? $converter->toInt(...) : $converter->toFloat(...))
: null,
'TINY' => $meta['length'] === 1 && $converter->convertBoolean
? $converter->toBool(...)
: $converter->toInt(...),
Expand Down
1 change: 0 additions & 1 deletion src/Database/Drivers/Engines/SQLServerEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ public function getForeignKeys(string $table): array

public function resolveColumnConverter(array $meta, TypeConverter $converter): ?\Closure
{
dump($meta);
return match ($meta['nativeType']) {
'timestamp' => null, // timestamp does not mean time in sqlsrv
'bit' => $converter->convertBoolean ? $converter->toBool(...) : $converter->toInt(...),
Expand Down
4 changes: 3 additions & 1 deletion src/Database/TypeConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ public function resolve(array $meta): ?\Closure
return match ($this->detectType($meta['nativeType'])) {
self::Integer => $this->toInt(...),
self::Float => $this->toFloat(...),
self::Decimal => $this->convertDecimal ? $this->toFloat(...) : null,
self::Decimal => $this->convertDecimal
? ($meta['scale'] === 0 ? $this->toInt(...) : $this->toFloat(...))
: null,
self::Boolean => $this->convertBoolean ? $this->toBool(...) : null,
self::DateTime, self::Date => $this->convertDateTime ? $this->toDateTime(...) : null,
self::Time => $this->convertDateTime ? $this->toTime(...) : null,
Expand Down

0 comments on commit 1d6103d

Please sign in to comment.