This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "SQLObject development repository".
The branch, master has been updated
via f53b85f9e682ed63c1a44d8e84811a0ec4204103 (commit)
via 0b6de541aca2b93a701f4bcc7a15dfd0525ad227 (commit)
via 65510b0f99f0e1435fb67551868b5e85ffc01a0a (commit)
via a2f5394f60dd625c8a1207ff863cb7b6a41361d2 (commit)
via 41699050f3cad73fd2863c0eeb2cc1a31c7f92d7 (commit)
via 8fbe39e241aea14a4657a8648d0f36d1bab618c1 (commit)
via 7a3a9978881d39a9a1a141af93b32606df08805e (commit)
via 183699a76fe8cc00e03d7c56dbd8af07b58f328e (commit)
via 6f4871059ab77831555fdc149a9dd652f7173f0f (commit)
via e1a1c01d09ce8ca2d70df8536467de4da0b0393e (commit)
via 99c87a77b33fe6d5b7f605204ce1274311c4a503 (commit)
via a26ef553dfdd6879507be1f8928b6e72572c7cf7 (commit)
from 24513bee32cdbb62d6ecf52fb5ab2045f7ab5386 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://sourceforge.net/p/sqlobject/sqlobject/ci/f53b85f9e682ed63c1a44d8e84811a0ec4204103
commit f53b85f9e682ed63c1a44d8e84811a0ec4204103
Author: Oleg Broytman <ph...@ph...>
Date: Wed Dec 10 00:13:24 2014 +0300
Skip microseconds test if the database doesn't support microseconds
diff --git a/sqlobject/tests/test_datetime.py b/sqlobject/tests/test_datetime.py
index 114e5ce..e1e1902 100644
--- a/sqlobject/tests/test_datetime.py
+++ b/sqlobject/tests/test_datetime.py
@@ -1,3 +1,4 @@
+import py.test
from sqlobject import *
from sqlobject.tests.dbtest import *
@@ -26,7 +27,6 @@ def test_dateTime():
assert dt1.col1.hour == _now.hour
assert dt1.col1.minute == _now.minute
assert dt1.col1.second == _now.second
- assert dt1.col1.microsecond == _now.microsecond
assert isinstance(dt1.col2, date)
assert not isinstance(dt1.col2, datetime)
@@ -38,6 +38,18 @@ def test_dateTime():
assert dt1.col3.hour == _now.hour
assert dt1.col3.minute == _now.minute
assert dt1.col3.second == _now.second
+
+def test_microseconds():
+ connection = getConnection()
+ if hasattr(connection, 'can_use_microseconds') and \
+ not connection.can_use_microseconds():
+ py.test.skip("The database doesn't support microseconds; microseconds are supported by MariaDB since version 5.3.0 and by MySQL since version 5.6.4.")
+
+ setupClass(DateTime1)
+ _now = datetime.now()
+ dt1 = DateTime1(col1=_now, col2=_now, col3=_now.time())
+
+ assert dt1.col1.microsecond == _now.microsecond
assert dt1.col3.microsecond == _now.microsecond
if mxdatetime_available:
http://sourceforge.net/p/sqlobject/sqlobject/ci/0b6de541aca2b93a701f4bcc7a15dfd0525ad227
commit 0b6de541aca2b93a701f4bcc7a15dfd0525ad227
Author: Oleg Broytman <ph...@ph...>
Date: Tue Dec 9 23:48:43 2014 +0300
Microseconds on MariaDB and MySQL require special handling
Columns to store microseconds have to be declared with precision 6:
TIME(6), DATETIME(6), TIMESTAMP(6).
diff --git a/docs/News.txt b/docs/News.txt
index 0b7a4b5..aef425a 100644
--- a/docs/News.txt
+++ b/docs/News.txt
@@ -16,7 +16,13 @@ Features & Interface
* DateTimeCol and TimeCol can read and write values with microseconds.
WARNING: microseconds are supported by MariaDB since version 5.3.0 and
- by MySQL since version 5.6.4.
+ by MySQL since version 5.6.4, and even these versions require special
+ handling: columns to store microseconds have to be declared with
+ precision 6: TIME(6), DATETIME(6), TIMESTAMP(6). SQLObject does the
+ right thing when creating a new database but existing databases have
+ to be changed: run something like
+ ``ALTER TABLE name MODIFY COLUMN col TIME(6)`` for every column that
+ you want to store microseconds.
WARNING: backward compatibility problem! Date/Time columns created
with microseconds cannot be read back from SQLite databases (and
diff --git a/sqlobject/col.py b/sqlobject/col.py
index 005e486..adbf002 100644
--- a/sqlobject/col.py
+++ b/sqlobject/col.py
@@ -320,7 +320,8 @@ class SOCol(object):
def _maxdbType(self):
return self._sqlType()
- def mysqlCreateSQL(self):
+ def mysqlCreateSQL(self, connection=None):
+ self.connection = connection
return ' '.join([self.dbName, self._mysqlType()] + self._extraSQL())
def postgresCreateSQL(self):
@@ -906,8 +907,8 @@ class SOForeignKey(SOKeyCol):
'sTLocalName': sTLocalName})
return constraint
- def mysqlCreateSQL(self):
- return SOKeyCol.mysqlCreateSQL(self)
+ def mysqlCreateSQL(self, connection=None):
+ return SOKeyCol.mysqlCreateSQL(self, connection)
def sybaseCreateSQL(self):
sql = SOKeyCol.sybaseCreateSQL(self)
@@ -1193,7 +1194,10 @@ class SODateTimeCol(SOCol):
return _validators
def _mysqlType(self):
- return 'DATETIME'
+ if self.connection and self.connection.can_use_microseconds():
+ return 'DATETIME(6)'
+ else:
+ return 'DATETIME'
def _postgresType(self):
return 'TIMESTAMP'
@@ -1324,7 +1328,10 @@ class SOTimeCol(SOCol):
return _validators
def _mysqlType(self):
- return 'TIME'
+ if self.connection and self.connection.can_use_microseconds():
+ return 'TIME(6)'
+ else:
+ return 'TIME'
def _postgresType(self):
return 'TIME'
@@ -1356,7 +1363,10 @@ class SOTimestampCol(SODateTimeCol):
SOCol.__init__(self, **kw)
def _mysqlType(self):
- return 'TIMESTAMP'
+ if self.connection and self.connection.can_use_microseconds():
+ return 'TIMESTAMP(6)'
+ else:
+ return 'TIMESTAMP'
class TimestampCol(Col):
baseClass = SOTimestampCol
diff --git a/sqlobject/mysql/mysqlconnection.py b/sqlobject/mysql/mysqlconnection.py
index 072df33..df02b9b 100644
--- a/sqlobject/mysql/mysqlconnection.py
+++ b/sqlobject/mysql/mysqlconnection.py
@@ -176,7 +176,7 @@ class MySQLConnection(DBAPI):
return col.mysqlCreateReferenceConstraint()
def createColumn(self, soClass, col):
- return col.mysqlCreateSQL()
+ return col.mysqlCreateSQL(self)
def createIndexSQL(self, soClass, index):
return index.mysqlCreateIndexSQL(soClass)
@@ -204,7 +204,7 @@ class MySQLConnection(DBAPI):
def addColumn(self, tableName, column):
self.query('ALTER TABLE %s ADD COLUMN %s' %
(tableName,
- column.mysqlCreateSQL()))
+ column.mysqlCreateSQL(self)))
def delColumn(self, sqlmeta, column):
self.query('ALTER TABLE %s DROP COLUMN %s' % (sqlmeta.table, column.dbName))
http://sourceforge.net/p/sqlobject/sqlobject/ci/65510b0f99f0e1435fb67551868b5e85ffc01a0a
commit 65510b0f99f0e1435fb67551868b5e85ffc01a0a
Author: Oleg Broytman <ph...@ph...>
Date: Tue Dec 9 23:09:32 2014 +0300
Microseconds are not supported by old version of MariaDB and MySQL
Microseconds are supported by MariaDB since version 5.3.0 and by MySQL
since version 5.6.4.
diff --git a/docs/News.txt b/docs/News.txt
index a2c6ec6..0b7a4b5 100644
--- a/docs/News.txt
+++ b/docs/News.txt
@@ -15,6 +15,9 @@ Features & Interface
* DateTimeCol and TimeCol can read and write values with microseconds.
+ WARNING: microseconds are supported by MariaDB since version 5.3.0 and
+ by MySQL since version 5.6.4.
+
WARNING: backward compatibility problem! Date/Time columns created
with microseconds cannot be read back from SQLite databases (and
perhaps other backends) with versions of SQLObject older than 1.7.
diff --git a/sqlobject/mysql/mysqlconnection.py b/sqlobject/mysql/mysqlconnection.py
index f3ea515..072df33 100644
--- a/sqlobject/mysql/mysqlconnection.py
+++ b/sqlobject/mysql/mysqlconnection.py
@@ -48,6 +48,8 @@ class MySQLConnection(DBAPI):
# MySQLdb > 1.2.1: both ascii and unicode
self.need_unicode = (self.module.version_info[:3] >= (1, 2, 1)) and (self.module.version_info[:3] < (1, 2, 2))
+ self._server_version = None
+ self._can_use_microseconds = None
DBAPI.__init__(self, **kw)
@classmethod
@@ -303,3 +305,35 @@ class MySQLConnection(DBAPI):
def dropDatabase(self):
self._createOrDropDatabase(op="DROP")
+
+ def server_version(self):
+ if self._server_version is not None:
+ return self._server_version
+ try:
+ server_version = self.queryOne("SELECT VERSION()")[0]
+ server_version = server_version.split('-', 1)
+ db_tag = "MySQL"
+ if len(server_version) == 2:
+ if "MariaDB" in server_version[1]:
+ db_tag = "MariaDB"
+ server_version = server_version[0]
+ server_version = tuple(int(v) for v in server_version.split('.'))
+ server_version = (server_version, db_tag)
+ except:
+ server_version = None # unknown
+ self._server_version = server_version
+ return server_version
+
+ def can_use_microseconds(self):
+ if self._can_use_microseconds is not None:
+ return self._can_use_microseconds
+ server_version = self.server_version()
+ if server_version is None:
+ return None
+ server_version, db_tag = server_version
+ if db_tag == "MariaDB":
+ can_use_microseconds = (server_version >= (5, 3, 0))
+ else: # MySQL
+ can_use_microseconds = (server_version >= (5, 6, 4))
+ self._can_use_microseconds = can_use_microseconds
+ return can_use_microseconds
http://sourceforge.net/p/sqlobject/sqlobject/ci/a2f5394f60dd625c8a1207ff863cb7b6a41361d2
commit a2f5394f60dd625c8a1207ff863cb7b6a41361d2
Author: Oleg Broytman <ph...@ph...>
Date: Tue Dec 9 19:14:56 2014 +0300
Development status: alpha
diff --git a/setup.py b/setup.py
index afe2430..af8f1d1 100755
--- a/setup.py
+++ b/setup.py
@@ -59,7 +59,7 @@ and `GitHub <https://github.com/sqlobject>`_.
:target: https://travis-ci.org/sqlobject/sqlobject
""",
classifiers=[
- "Development Status :: 5 - Production/Stable",
+ "Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)",
"Programming Language :: Python",
http://sourceforge.net/p/sqlobject/sqlobject/ci/41699050f3cad73fd2863c0eeb2cc1a31c7f92d7
commit 41699050f3cad73fd2863c0eeb2cc1a31c7f92d7
Merge: 24513be 8fbe39e
Author: Oleg Broytman <ph...@ph...>
Date: Tue Dec 9 19:14:06 2014 +0300
Merge branch '1.7'
diff --cc setup.py
index 1309237,adf5161..afe2430
--- a/setup.py
+++ b/setup.py
@@@ -51,9 -51,12 +51,12 @@@ applications
Supports MySQL, PostgreSQL, SQLite, Firebird, Sybase, MSSQL and MaxDB (SAPDB).
- For development see the git repositories at
- http://sourceforge.net/p/sqlobject/_list/git and
- https://github.com/sqlobject
+ For development see the projects at
+ `SourceForge <http://sourceforge.net/projects/sqlobject/>`_
+ and `GitHub <https://github.com/sqlobject>`_.
+
-.. image:: https://travis-ci.org/sqlobject/sqlobject.svg?branch=1.7
++.. image:: https://travis-ci.org/sqlobject/sqlobject.svg?branch=master
+ :target: https://travis-ci.org/sqlobject/sqlobject
""",
classifiers=[
"Development Status :: 5 - Production/Stable",
-----------------------------------------------------------------------
Summary of changes:
docs/News.txt | 9 ++++++++
setup.py | 13 ++++++++---
sqlobject/col.py | 22 +++++++++++++++-----
sqlobject/mysql/mysqlconnection.py | 38 ++++++++++++++++++++++++++++++++++-
sqlobject/tests/test_datetime.py | 14 ++++++++++++-
5 files changed, 83 insertions(+), 13 deletions(-)
hooks/post-receive
--
SQLObject development repository
|