导表工具增加布尔值
This commit is contained in:
parent
2f5f37f546
commit
67e87cbc96
@ -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
|
||||
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user