Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
erp5_rtl_support
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Romain Courteaud
erp5_rtl_support
Commits
3b41d9bb
Commit
3b41d9bb
authored
Sep 22, 2016
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5Type.patches.sqltest: Add support for type="datetime".
parent
b700cece
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
0 deletions
+13
-0
product/ERP5Type/patches/sqltest.py
product/ERP5Type/patches/sqltest.py
+13
-0
No files found.
product/ERP5Type/patches/sqltest.py
View file @
3b41d9bb
...
...
@@ -11,6 +11,7 @@
#
##############################################################################
from
Shared.DC.ZRDB.sqltest
import
*
from
Shared.DC.ZRDB
import
sqltest
list_type_list
=
list
,
tuple
,
set
,
frozenset
,
dict
...
...
@@ -61,6 +62,16 @@ if 1: # For easy diff with original
except
ValueError
:
raise
ValueError
,
(
'Invalid floating-point value for <em>%s</em>'
%
name
)
elif
t
.
startswith
(
'datetime'
):
# For subsecond precision, use 'datetime(N)' MySQL type,
# where N is the number of digits after the decimal point.
n
=
0
if
t
==
'datetime'
else
int
(
t
[
9
])
try
:
v
=
(
v
if
isinstance
(
v
,
DateTime
)
else
DateTime
(
v
)).
toZone
(
'UTC'
)
return
"'%s%s'"
%
(
v
.
ISO
(),
(
'.%06u'
%
(
v
.
micros
()
%
1000000
))[:
1
+
n
]
if
n
else
''
)
except
Exception
:
t
=
'datetime'
else
:
if
not
isinstance
(
v
,
(
str
,
unicode
)):
...
...
@@ -94,3 +105,5 @@ if 1: # For easy diff with original
return
"%s in (%s)"
%
(
self
.
column
,
vs
)
return
"%s %s %s"
%
(
self
.
column
,
self
.
op
,
vs
[
0
])
SQLTest
.
render
=
SQLTest
.
__call__
=
render
sqltest
.
valid_type
=
((
'int'
,
'float'
,
'string'
,
'nb'
,
'datetime'
)
+
tuple
(
'datetime(%s)'
%
x
for
x
in
xrange
(
7
))).
__contains__
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment