Browse Source

Merge pull request #14276 from leela/fix-precision

fix: use decimal digits precision 9 instead of 6 while creating schema
version-14
Leela vadlamudi 3 years ago
committed by GitHub
parent
commit
dc49d4d45c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 8 deletions
  1. +4
    -4
      frappe/database/mariadb/database.py
  2. +4
    -4
      frappe/database/postgres/database.py
  3. +2
    -0
      frappe/database/schema.py

+ 4
- 4
frappe/database/mariadb/database.py View File

@@ -22,11 +22,11 @@ class MariaDBDatabase(Database):
def setup_type_map(self): def setup_type_map(self):
self.db_type = 'mariadb' self.db_type = 'mariadb'
self.type_map = { self.type_map = {
'Currency': ('decimal', '18,6'),
'Currency': ('decimal', '21,9'),
'Int': ('int', '11'), 'Int': ('int', '11'),
'Long Int': ('bigint', '20'), 'Long Int': ('bigint', '20'),
'Float': ('decimal', '18,6'),
'Percent': ('decimal', '18,6'),
'Float': ('decimal', '21,9'),
'Percent': ('decimal', '21,9'),
'Check': ('int', '1'), 'Check': ('int', '1'),
'Small Text': ('text', ''), 'Small Text': ('text', ''),
'Long Text': ('longtext', ''), 'Long Text': ('longtext', ''),
@@ -51,7 +51,7 @@ class MariaDBDatabase(Database):
'Color': ('varchar', self.VARCHAR_LEN), 'Color': ('varchar', self.VARCHAR_LEN),
'Barcode': ('longtext', ''), 'Barcode': ('longtext', ''),
'Geolocation': ('longtext', ''), 'Geolocation': ('longtext', ''),
'Duration': ('decimal', '18,6'),
'Duration': ('decimal', '21,9'),
'Icon': ('varchar', self.VARCHAR_LEN) 'Icon': ('varchar', self.VARCHAR_LEN)
} }




+ 4
- 4
frappe/database/postgres/database.py View File

@@ -32,11 +32,11 @@ class PostgresDatabase(Database):
def setup_type_map(self): def setup_type_map(self):
self.db_type = 'postgres' self.db_type = 'postgres'
self.type_map = { self.type_map = {
'Currency': ('decimal', '18,6'),
'Currency': ('decimal', '21,9'),
'Int': ('bigint', None), 'Int': ('bigint', None),
'Long Int': ('bigint', None), 'Long Int': ('bigint', None),
'Float': ('decimal', '18,6'),
'Percent': ('decimal', '18,6'),
'Float': ('decimal', '21,9'),
'Percent': ('decimal', '21,9'),
'Check': ('smallint', None), 'Check': ('smallint', None),
'Small Text': ('text', ''), 'Small Text': ('text', ''),
'Long Text': ('text', ''), 'Long Text': ('text', ''),
@@ -61,7 +61,7 @@ class PostgresDatabase(Database):
'Color': ('varchar', self.VARCHAR_LEN), 'Color': ('varchar', self.VARCHAR_LEN),
'Barcode': ('text', ''), 'Barcode': ('text', ''),
'Geolocation': ('text', ''), 'Geolocation': ('text', ''),
'Duration': ('decimal', '18,6'),
'Duration': ('decimal', '21,9'),
'Icon': ('varchar', self.VARCHAR_LEN) 'Icon': ('varchar', self.VARCHAR_LEN)
} }




+ 2
- 0
frappe/database/schema.py View File

@@ -303,6 +303,8 @@ def get_definition(fieldtype, precision=None, length=None):
size = d[1] if d[1] else None size = d[1] if d[1] else None


if size: if size:
# This check needs to exist for backward compatibility.
# Till V13, default size used for float, currency and percent are (18, 6).
if fieldtype in ["Float", "Currency", "Percent"] and cint(precision) > 6: if fieldtype in ["Float", "Currency", "Percent"] and cint(precision) > 6:
size = '21,9' size = '21,9'




Loading…
Cancel
Save