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 ae482753099d74cdb16f83d1124a77acaa3856d7 (commit)
via 5d316860a1259d7acbccc4d11166c27329336fb0 (commit)
via 9986fc15b70e281f85d6645f43d4ac1954078d51 (commit)
via ebcecd543fe7a98f2dd66c7af4c10ee877960527 (commit)
via 898ea2a2482a7cab8ab1d835eaf797d33ea6fdd9 (commit)
from 0a6f19d2d975fc5ac7a5d25259add57bee7f6cfe (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/ae482753099d74cdb16f83d1124a77acaa3856d7
commit ae482753099d74cdb16f83d1124a77acaa3856d7
Author: Oleg Broytman <ph...@ph...>
Date: Wed Nov 8 08:52:00 2017 +0300
Tests: Add a test for truediv on SQLite
diff --git a/sqlobject/tests/test_sqlite.py b/sqlobject/tests/test_sqlite.py
index 442ecf3..4e9611a 100644
--- a/sqlobject/tests/test_sqlite.py
+++ b/sqlobject/tests/test_sqlite.py
@@ -1,7 +1,9 @@
+import math
import threading
import pytest
-from sqlobject import SQLObject, StringCol
+from sqlobject import SQLObject, StringCol, FloatCol
from sqlobject.compat import string_type
+from sqlobject.sqlbuilder import Select
from sqlobject.tests.dbtest import getConnection, setupClass, supports
from sqlobject.tests.dbtest import setSQLiteConnectionFactory
from .test_basic import SOTestSO1
@@ -144,3 +146,29 @@ def test_list_databases():
def test_list_tables():
setupClass(SOTestSO1)
assert SOTestSO1.sqlmeta.table in connection.listTables()
+
+
+class SQLiteTruedivTest(SQLObject):
+ value = FloatCol()
+
+
+def test_truediv():
+ setupClass(SQLiteTruedivTest)
+
+ if SQLiteTruedivTest._connection.dbName == "sqlite":
+ if not SQLiteTruedivTest._connection.using_sqlite2:
+ pytest.skip("These tests require SQLite v2+")
+
+ def SQLiteConnectionFactory(sqlite):
+ class MyConnection(sqlite.Connection):
+ def __init__(self, *args, **kwargs):
+ super(MyConnection, self).__init__(*args, **kwargs)
+ self.create_function("floor", 1, math.floor)
+ return MyConnection
+
+ setSQLiteConnectionFactory(SQLiteTruedivTest, SQLiteConnectionFactory)
+
+ SQLiteTruedivTest(value=-5.0)
+ assert SQLiteTruedivTest._connection.queryAll(
+ SQLiteTruedivTest._connection.sqlrepr(
+ Select(SQLiteTruedivTest.q.value // 4)))[0][0] == -2
http://sourceforge.net/p/sqlobject/sqlobject/ci/5d316860a1259d7acbccc4d11166c27329336fb0
commit 5d316860a1259d7acbccc4d11166c27329336fb0
Author: Oleg Broytman <ph...@ph...>
Date: Wed Nov 8 08:25:34 2017 +0300
Docs: Merged a pull request by Michael S. Root
[skip ci]
diff --git a/ANNOUNCE.rst b/ANNOUNCE.rst
index 31ffed8..bf5903c 100644
--- a/ANNOUNCE.rst
+++ b/ANNOUNCE.rst
@@ -22,7 +22,7 @@ I'm pleased to announce version 3.4.1, the first bugfix release of branch
What's new in SQLObject
=======================
-Contributor for this release is Shailesh Mungikar.
+Contributors for this release are Shailesh Mungikar, Michael S. Root.
For a more complete list, please see the news:
http://sqlobject.org/News.html
diff --git a/docs/Authors.rst b/docs/Authors.rst
index 1d0a063..3f3d55b 100644
--- a/docs/Authors.rst
+++ b/docs/Authors.rst
@@ -35,6 +35,7 @@ Contributions have been made by:
* Nathan Edwards <nje5 at georgetown.edu>
* Lutz Steinborn <l.steinborn at 4c-gmbh.de>
* Shailesh Mungikar <shailesh.mungikar at druva.com>
+* Michael S. Root <miker at tippett.com>
* Oleg Broytman <ph...@ph...>
.. image:: https://sourceforge.net/sflogo.php?group_id=74338&type=10
diff --git a/docs/News.rst b/docs/News.rst
index 8bc7582..ae62e53 100644
--- a/docs/News.rst
+++ b/docs/News.rst
@@ -10,6 +10,12 @@ News
SQLObject 3.5.0 (master)
========================
+Features
+--------
+
+* Add Python3 special methods for division to SQLExpression.
+ Pull request by Michael S. Root.
+
Drivers
-------
http://sourceforge.net/p/sqlobject/sqlobject/ci/9986fc15b70e281f85d6645f43d4ac1954078d51
commit 9986fc15b70e281f85d6645f43d4ac1954078d51
Merge: 0a6f19d ebcecd5
Author: Oleg Broytman <ph...@ph...>
Date: Wed Nov 8 08:18:53 2017 +0300
Merge pull request #141 from mike1158/master
Add Python3 special methods for division to SQLExpression
http://sourceforge.net/p/sqlobject/sqlobject/ci/ebcecd543fe7a98f2dd66c7af4c10ee877960527
commit ebcecd543fe7a98f2dd66c7af4c10ee877960527
Author: Michael S. Root <mi...@ti...>
Date: Tue Nov 7 17:32:36 2017 -0800
Added minimal unit tests for __truediv__ and __floordiv__
diff --git a/sqlobject/tests/test_sqlbuilder.py b/sqlobject/tests/test_sqlbuilder.py
index 9a3b6e3..1d2c850 100644
--- a/sqlobject/tests/test_sqlbuilder.py
+++ b/sqlobject/tests/test_sqlbuilder.py
@@ -57,6 +57,14 @@ def test_modulo():
"(((so_test_sql_builder.so_value) % (2)) = (0))"
+def test_division():
+ SOTestSQLBuilder(name='test', so_value=-11)
+ assert sqlrepr(SOTestSQLBuilder.q.so_value / 4 == -2.75, 'mysql') == \
+ "(((so_test_sql_builder.so_value) / (4)) = (-2.75))"
+ assert sqlrepr(SOTestSQLBuilder.q.so_value // 4 == -3, 'mysql') == \
+ "((FLOOR(((so_test_sql_builder.so_value) / (4)))) = (-3))"
+
+
def test_str_or_sqlrepr():
select = Select(['id', 'name'], staticTables=['employees'],
where='value>0', orderBy='id')
http://sourceforge.net/p/sqlobject/sqlobject/ci/898ea2a2482a7cab8ab1d835eaf797d33ea6fdd9
commit 898ea2a2482a7cab8ab1d835eaf797d33ea6fdd9
Author: Michael S. Root <mi...@ti...>
Date: Mon Oct 30 12:00:11 2017 -0700
Add Python3 special methods for division to SQLExpression
Adds __truediv__ and __floordiv__ (and reciprocals) to better support using
SQLExpression objects in Pythonn3.
Note that __floordiv__ is NOT equivalent to SQL's 'DIV' operator, so the
SQL FLOOR function is used in combination with the / operator.
Should be backwards-compatible with Python2.
diff --git a/sqlobject/sqlbuilder.py b/sqlobject/sqlbuilder.py
index e87ba70..5178c73 100644
--- a/sqlobject/sqlbuilder.py
+++ b/sqlobject/sqlbuilder.py
@@ -137,6 +137,18 @@ class SQLExpression:
def __rdiv__(self, other):
return SQLOp("/", other, self)
+ def __truediv__(self, other):
+ return SQLOp("/", self, other)
+
+ def __rtruediv__(self, other):
+ return SQLOp("/", other, self)
+
+ def __floordiv__(self, other):
+ return SQLConstant("FLOOR")(SQLOp("/", self, other))
+
+ def __rfloordiv__(self, other):
+ return SQLConstant("FLOOR")(SQLOp("/", other, self))
+
def __pos__(self):
return SQLPrefix("+", self)
-----------------------------------------------------------------------
Summary of changes:
ANNOUNCE.rst | 2 +-
docs/Authors.rst | 1 +
docs/News.rst | 6 ++++++
sqlobject/sqlbuilder.py | 12 ++++++++++++
sqlobject/tests/test_sqlbuilder.py | 8 ++++++++
sqlobject/tests/test_sqlite.py | 30 +++++++++++++++++++++++++++++-
6 files changed, 57 insertions(+), 2 deletions(-)
hooks/post-receive
--
SQLObject development repository
|