{"action":"created","issue":{"url":"https://api.github.com/repos/ponyorm/pony/issues/190","repository_url":"https://api.github.com/repos/ponyorm/pony","labels_url":"https://api.github.com/repos/ponyorm/pony/issues/190/labels{/name}","comments_url":"https://api.github.com/repos/ponyorm/pony/issues/190/comments","events_url":"https://api.github.com/repos/ponyorm/pony/issues/190/events","html_url":"https://github.com/ponyorm/pony/issues/190","id":173736135,"number":190,"title":"Timedelta not supported when using pymysql","user":{"login":"mikkiweesenaar","id":17587486,"avatar_url":"https://avatars.githubusercontent.com/u/17587486?v=3","gravatar_id":"","url":"https://api.github.com/users/mikkiweesenaar","html_url":"https://github.com/mikkiweesenaar","followers_url":"https://api.github.com/users/mikkiweesenaar/followers","following_url":"https://api.github.com/users/mikkiweesenaar/following{/other_user}","gists_url":"https://api.github.com/users/mikkiweesenaar/gists{/gist_id}","starred_url":"https://api.github.com/users/mikkiweesenaar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikkiweesenaar/subscriptions","organizations_url":"https://api.github.com/users/mikkiweesenaar/orgs","repos_url":"https://api.github.com/users/mikkiweesenaar/repos","events_url":"https://api.github.com/users/mikkiweesenaar/events{/privacy}","received_events_url":"https://api.github.com/users/mikkiweesenaar/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ponyorm/pony/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":{"login":"kozlovsky","id":2931136,"avatar_url":"https://avatars.githubusercontent.com/u/2931136?v=3","gravatar_id":"","url":"https://api.github.com/users/kozlovsky","html_url":"https://github.com/kozlovsky","followers_url":"https://api.github.com/users/kozlovsky/followers","following_url":"https://api.github.com/users/kozlovsky/following{/other_user}","gists_url":"https://api.github.com/users/kozlovsky/gists{/gist_id}","starred_url":"https://api.github.com/users/kozlovsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kozlovsky/subscriptions","organizations_url":"https://api.github.com/users/kozlovsky/orgs","repos_url":"https://api.github.com/users/kozlovsky/repos","events_url":"https://api.github.com/users/kozlovsky/events{/privacy}","received_events_url":"https://api.github.com/users/kozlovsky/received_events","type":"User","site_admin":false},"assignees":[{"login":"kozlovsky","id":2931136,"avatar_url":"https://avatars.githubusercontent.com/u/2931136?v=3","gravatar_id":"","url":"https://api.github.com/users/kozlovsky","html_url":"https://github.com/kozlovsky","followers_url":"https://api.github.com/users/kozlovsky/followers","following_url":"https://api.github.com/users/kozlovsky/following{/other_user}","gists_url":"https://api.github.com/users/kozlovsky/gists{/gist_id}","starred_url":"https://api.github.com/users/kozlovsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kozlovsky/subscriptions","organizations_url":"https://api.github.com/users/kozlovsky/orgs","repos_url":"https://api.github.com/users/kozlovsky/repos","events_url":"https://api.github.com/users/kozlovsky/events{/privacy}","received_events_url":"https://api.github.com/users/kozlovsky/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/ponyorm/pony/milestones/7","html_url":"https://github.com/ponyorm/pony/milestones/0.6.7","labels_url":"https://api.github.com/repos/ponyorm/pony/milestones/7/labels","id":1972220,"number":7,"title":"0.6.7","description":null,"creator":{"login":"kozlovsky","id":2931136,"avatar_url":"https://avatars.githubusercontent.com/u/2931136?v=3","gravatar_id":"","url":"https://api.github.com/users/kozlovsky","html_url":"https://github.com/kozlovsky","followers_url":"https://api.github.com/users/kozlovsky/followers","following_url":"https://api.github.com/users/kozlovsky/following{/other_user}","gists_url":"https://api.github.com/users/kozlovsky/gists{/gist_id}","starred_url":"https://api.github.com/users/kozlovsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kozlovsky/subscriptions","organizations_url":"https://api.github.com/users/kozlovsky/orgs","repos_url":"https://api.github.com/users/kozlovsky/repos","events_url":"https://api.github.com/users/kozlovsky/events{/privacy}","received_events_url":"https://api.github.com/users/kozlovsky/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":1,"state":"open","created_at":"2016-08-30T12:00:50Z","updated_at":"2016-08-30T12:00:50Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2016-08-29T09:42:01Z","updated_at":"2016-08-30T12:06:21Z","closed_at":"2016-08-30T11:59:57Z","body":"## Environment:\r\nMacOSX El Capitan with Python 3.5.1.\r\n`python3 -c \"import pony; import pymysql; print(pony.__version__, ' & ', pymysql.__version__);\"`\r\n`0.6.6  &  0.7.6.None `\r\n\r\n\r\n## Reproduction scenario:\r\n```\r\nfrom datetime import timedelta\r\nimport unittest\r\n\r\nfrom pony.orm import *\r\nfrom pony.orm.tests.testutils import *\r\n\r\n\r\n#db = Database('sqlite', ':memory:')\r\ndb = Database('mysql', host='localhost', port=3306, user='myuser', passwd='mypass', db='mydb')\r\n\r\n\r\nclass TimeDeltaEntities(db.Entity):\r\n    id = PrimaryKey(int)\r\n    t = Required(timedelta)\r\n\r\ndb.generate_mapping(create_tables=True)\r\n\r\nwith db_session:\r\n    TimeDeltaEntities(id=1, t=timedelta(minutes=1))\r\n    TimeDeltaEntities(id=2, t=timedelta(hours=1))\r\n\r\n\r\nclass TestTimeDelta(unittest.TestCase):\r\n\r\n    @db_session\r\n    def test_1(self):\r\n        timedeltas = TimeDeltaEntities.select()\r\n        self.assertEqual(len(timedeltas), 2)\r\n        t1, t2 = timedeltas\r\n        self.assertTrue(t1.t.seconds, 60 * 1)\r\n        self.assertTrue(t2.t.seconds, 60 * 60 * 1)\r\n```\r\n\r\n## Actual behaviour:\r\n```\r\n======================================================================\r\nERROR: Failure: CommitException (TypeError: <lambda>() takes exactly 1 argument (2 given))\r\n----------------------------------------------------------------------\r\nTraceback (most recent call last):\r\n  File \"/Library/Python/2.7/site-packages/nose/loader.py\", line 418, in loadTestsFromName\r\n    addr.filename, addr.module)\r\n  File \"/Library/Python/2.7/site-packages/nose/importer.py\", line 47, in importFromPath\r\n    return self.importFromDir(dir_path, fqname)\r\n  File \"/Library/Python/2.7/site-packages/nose/importer.py\", line 94, in importFromDir\r\n    mod = load_module(part_fqname, fh, filename, desc)\r\n  File \"/Users/mikkiweesenaar/git/pony/pony/orm/tests/test_timedelta.py\", line 20, in <module>\r\n    TimeDeltaEntities(id=2, t=timedelta(hours=1))\r\n  File \"/Users/mikkiweesenaar/git/pony/pony/orm/core.py\", line 378, in __exit__\r\n    commit()\r\n  File \"<auto generated wrapper of commit() function>\", line 2, in commit\r\n  File \"/Users/mikkiweesenaar/git/pony/pony/utils/utils.py\", line 66, in cut_traceback\r\n    return func(*args, **kwargs)\r\n  File \"/Users/mikkiweesenaar/git/pony/pony/orm/core.py\", line 292, in commit\r\n    transact_reraise(CommitException, exceptions)\r\n  File \"/Users/mikkiweesenaar/git/pony/pony/orm/core.py\", line 276, in transact_reraise\r\n    reraise(exc_class, new_exc, tb)\r\n  File \"/Users/mikkiweesenaar/git/pony/pony/orm/core.py\", line 286, in commit\r\n    try: primary_cache.commit()\r\n  File \"/Users/mikkiweesenaar/git/pony/pony/orm/core.py\", line 1524, in commit\r\n    if cache.modified: cache.flush()\r\n  File \"/Users/mikkiweesenaar/git/pony/pony/orm/core.py\", line 1585, in flush\r\n    if obj is not None: obj._save_()\r\n  File \"/Users/mikkiweesenaar/git/pony/pony/orm/core.py\", line 4773, in _save_\r\n    if status == 'created': obj._save_created_()\r\n  File \"/Users/mikkiweesenaar/git/pony/pony/orm/core.py\", line 4670, in _save_created_\r\n    else: database._exec_sql(sql, arguments, start_transaction=True)\r\n  File \"/Users/mikkiweesenaar/git/pony/pony/orm/core.py\", line 683, in _exec_sql\r\n    connection = cache.reconnect(e)\r\n  File \"/Users/mikkiweesenaar/git/pony/pony/orm/core.py\", line 1491, in reconnect\r\n    if not provider.should_reconnect(exc): reraise(*sys.exc_info())\r\n  File \"/Users/mikkiweesenaar/git/pony/pony/orm/core.py\", line 681, in _exec_sql\r\n    try: new_id = provider.execute(cursor, sql, arguments, returning_id)\r\n  File \"<auto generated wrapper of execute() function>\", line 2, in execute\r\n  File \"/Users/mikkiweesenaar/git/pony/pony/orm/dbapiprovider.py\", line 48, in wrap_dbapi_exceptions\r\n    try: return func(provider, *args, **kwargs)\r\n  File \"/Users/mikkiweesenaar/git/pony/pony/orm/dbapiprovider.py\", line 240, in execute\r\n    else: cursor.execute(sql, arguments)\r\n  File \"/Library/Python/2.7/site-packages/pymysql/cursors.py\", line 159, in execute\r\n    query = self.mogrify(query, args)\r\n  File \"/Library/Python/2.7/site-packages/pymysql/cursors.py\", line 138, in mogrify\r\n    query = query % self._escape_args(args, conn)\r\n  File \"/Library/Python/2.7/site-packages/pymysql/cursors.py\", line 113, in _escape_args\r\n    return tuple(conn.escape(arg) for arg in args)\r\n  File \"/Library/Python/2.7/site-packages/pymysql/cursors.py\", line 113, in <genexpr>\r\n    return tuple(conn.escape(arg) for arg in args)\r\n  File \"/Library/Python/2.7/site-packages/pymysql/connections.py\", line 793, in escape\r\n    return escape_item(obj, self.charset, mapping=mapping)\r\n  File \"/Library/Python/2.7/site-packages/pymysql/converters.py\", line 26, in escape_item\r\n    val = encoder(val, mapping)\r\nCommitException: TypeError: <lambda>() takes exactly 1 argument (2 given)\r\n```\r\n\r\n## Expected behaviour:\r\nI would have expected that the behaviour would be the same for both sqlite as mysql - that it would just work. I think it is due to https://github.com/ponyorm/pony/blob/e66d0feaaf7b49e5283c9b3d2b3d779643b4b13d/pony/orm/dbproviders/mysql.py#L28 .\r\nIf I comment this line out, the code works fine."},"comment":{"url":"https://api.github.com/repos/ponyorm/pony/issues/comments/243417902","html_url":"https://github.com/ponyorm/pony/issues/190#issuecomment-243417902","issue_url":"https://api.github.com/repos/ponyorm/pony/issues/190","id":243417902,"user":{"login":"mikkiweesenaar","id":17587486,"avatar_url":"https://avatars.githubusercontent.com/u/17587486?v=3","gravatar_id":"","url":"https://api.github.com/users/mikkiweesenaar","html_url":"https://github.com/mikkiweesenaar","followers_url":"https://api.github.com/users/mikkiweesenaar/followers","following_url":"https://api.github.com/users/mikkiweesenaar/following{/other_user}","gists_url":"https://api.github.com/users/mikkiweesenaar/gists{/gist_id}","starred_url":"https://api.github.com/users/mikkiweesenaar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikkiweesenaar/subscriptions","organizations_url":"https://api.github.com/users/mikkiweesenaar/orgs","repos_url":"https://api.github.com/users/mikkiweesenaar/repos","events_url":"https://api.github.com/users/mikkiweesenaar/events{/privacy}","received_events_url":"https://api.github.com/users/mikkiweesenaar/received_events","type":"User","site_admin":false},"created_at":"2016-08-30T12:06:20Z","updated_at":"2016-08-30T12:06:20Z","body":"I tried to make tests for it, but apart from really telling the code where my mysql instance is, I wasn't quickly able to create a test.\r\nCan you give me a quick hint with how I can make (some) test(s) for it? :)"}}
{"actor":{"display_login":"mikkiweesenaar"}}