Skip to content

Commit 170c5ed

Browse files
committed
fix: add support for float and decimal column types
- Added float type mapping (FLOAT for most databases, REAL for SQLite) - Added decimal type mapping with precision and scale support - Fixes 'no such table' errors caused by undefined float type defaulting to VARCHAR
1 parent e273d6a commit 170c5ed

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

golang/database.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,24 @@ func (db *Database) getSQLType(colType ColumnType) string {
197197
return "DATETIME"
198198
case "text":
199199
return "TEXT"
200+
case "float":
201+
// Use REAL for SQLite, FLOAT for others
202+
if db.driver == "sqlite3" {
203+
return "REAL"
204+
}
205+
return "FLOAT"
206+
case "decimal":
207+
precision := 10
208+
scale := 2
209+
if colType.Args != nil {
210+
if p, ok := colType.Args["precision"].(float64); ok {
211+
precision = int(p)
212+
}
213+
if s, ok := colType.Args["scale"].(float64); ok {
214+
scale = int(s)
215+
}
216+
}
217+
return fmt.Sprintf("DECIMAL(%d, %d)", precision, scale)
200218
case "boolean":
201219
// MSSQL uses BIT instead of BOOLEAN
202220
if db.driver == "sqlserver" {

0 commit comments

Comments
 (0)