导表工具增加布尔值

This commit is contained in:
chenxi 2023-05-10 17:03:52 +08:00
parent 2f5f37f546
commit 67e87cbc96
2 changed files with 16 additions and 2 deletions

View File

@ -4,7 +4,7 @@ import util
import base64
SIMPLE_TYPE = ['int', 'long', 'string', 'str', 'float', 'double', 'atom', 'int32', 'int64']
SIMPLE_TYPE = ['int', 'long', 'string', 'str', 'float', 'double', 'atom', 'int32', 'int64', 'bool']
ERL_TYPE_MAPPING = {
'int': 'integer',
'int32': 'integer',
@ -63,6 +63,13 @@ def format_data(value, t):
if value == 'null':
return 0.0
raise Exception('数据应该是小数: %s' % value)
elif t == 'bool':
try:
return str(value).lower()
except ValueError:
if value == 'null':
return 'false'
raise Exception('数据应该是布尔: %s' % value)
return value

View File

@ -4,7 +4,7 @@ import util
import base64
SIMPLE_TYPE = ['int', 'long', 'string', 'str', 'float', 'double', 'atom', 'int32', 'int64']
SIMPLE_TYPE = ['int', 'long', 'string', 'str', 'float', 'double', 'atom', 'int32', 'int64', 'bool']
ERL_TYPE_MAPPING = {
'int': 'integer',
'int32': 'integer',
@ -63,6 +63,13 @@ def format_data(value, t):
if value == 'null':
return 0.0
raise Exception('数据应该是小数: %s' % value)
elif t == 'bool':
try:
return str(value).lower()
except ValueError:
if value == 'null':
return 'false'
raise Exception('数据应该是布尔: %s' % value)
return value