{"action":"created","comment":{"url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/pulls/comments/38568089","id":38568089,"diff_hunk":"@@ -0,0 +1,131 @@\n+__author__ = 'Haleemur Ali'\n+\"\"\"\n+Tests to validate that the correct delete statement is\n+issued for the redshift dialect of SQL.\n+\n+These tests use a simple transaction schema.\n+\n+For simple delete statments that don't have a ``WHERE`` clause\n+or whose ``WHERE`` clause only refers to columns from the\n+target table, the emitted query should match that emitted\n+for the postgresql dialect.\n+\n+However, for more complex queries, an extra ``USING`` clause is required.\n+\n+For example, the following is valid in Postgresql:\n+\n+.. :code-block: sql\n+\n+    DELETE FROM customers\n+    WHERE customers.id = orders.customer_id\n+      AND orders.id < 100\n+\n+\n+This same query needs to be written like this in Redshift:\n+\n+.. :code-block: sql\n+    DELETE FROM customers\n+    USING orders\n+    WHERE customers.id = orders.customer_id\n+      AND orders.id < 100\n+\n+\"\"\"\n+\n+from redshift_sqlalchemy.dialect import RedshiftDialect\n+import sqlalchemy as sa\n+\n+\n+meta = sa.MetaData()\n+\n+customers = sa.Table(\n+    'customers', meta,\n+    sa.Column('id', sa.Integer, primary_key=True, autoincrement=False),\n+    sa.Column('first_name', sa.String(128)),\n+    sa.Column('last_name', sa.String(128)),\n+    sa.Column('email', sa.String(255))\n+)\n+\n+orders = sa.Table(\n+    'orders', meta,\n+    sa.Column('id', sa.Integer, primary_key=True, autoincrement=False),\n+    sa.Column('customer_id', sa.Integer),\n+    sa.Column('total_invoiced', sa.Numeric(12, 4)),\n+    sa.Column('discount_invoiced', sa.Numeric(12, 4)),\n+    sa.Column('grandtotal_invoiced', sa.Numeric(12, 4)),\n+    sa.Column('created_at', sa.DateTime),\n+    sa.Column('updated_at', sa.DateTime)\n+)\n+\n+items = sa.Table(\n+    'items', meta,","path":"tests/test_delete_stmt.py","position":60,"original_position":60,"commit_id":"1d7040ba063d5c4ba3e879b74f26e8db7a4cfca3","original_commit_id":"1d7040ba063d5c4ba3e879b74f26e8db7a4cfca3","user":{"login":"graingert","id":413772,"avatar_url":"https://avatars.githubusercontent.com/u/413772?v=3","gravatar_id":"","url":"https://api.github.com/users/graingert","html_url":"https://github.com/graingert","followers_url":"https://api.github.com/users/graingert/followers","following_url":"https://api.github.com/users/graingert/following{/other_user}","gists_url":"https://api.github.com/users/graingert/gists{/gist_id}","starred_url":"https://api.github.com/users/graingert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/graingert/subscriptions","organizations_url":"https://api.github.com/users/graingert/orgs","repos_url":"https://api.github.com/users/graingert/repos","events_url":"https://api.github.com/users/graingert/events{/privacy}","received_events_url":"https://api.github.com/users/graingert/received_events","type":"User","site_admin":false},"body":"I mean\r\n`DELETE FROM \"ham, spam\"`","created_at":"2015-09-02T18:37:56Z","updated_at":"2015-09-02T18:37:56Z","html_url":"https://github.com/graingert/redshift_sqlalchemy/pull/36#discussion_r38568089","pull_request_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/pulls/36","_links":{"self":{"href":"https://api.github.com/repos/graingert/redshift_sqlalchemy/pulls/comments/38568089"},"html":{"href":"https://github.com/graingert/redshift_sqlalchemy/pull/36#discussion_r38568089"},"pull_request":{"href":"https://api.github.com/repos/graingert/redshift_sqlalchemy/pulls/36"}}},"pull_request":{"url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/pulls/36","id":44001138,"html_url":"https://github.com/graingert/redshift_sqlalchemy/pull/36","diff_url":"https://github.com/graingert/redshift_sqlalchemy/pull/36.diff","patch_url":"https://github.com/graingert/redshift_sqlalchemy/pull/36.patch","issue_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/issues/36","number":36,"state":"open","locked":false,"title":"Fix DELETE statement for Redshift Dialect","user":{"login":"haleemur","id":6108231,"avatar_url":"https://avatars.githubusercontent.com/u/6108231?v=3","gravatar_id":"","url":"https://api.github.com/users/haleemur","html_url":"https://github.com/haleemur","followers_url":"https://api.github.com/users/haleemur/followers","following_url":"https://api.github.com/users/haleemur/following{/other_user}","gists_url":"https://api.github.com/users/haleemur/gists{/gist_id}","starred_url":"https://api.github.com/users/haleemur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haleemur/subscriptions","organizations_url":"https://api.github.com/users/haleemur/orgs","repos_url":"https://api.github.com/users/haleemur/repos","events_url":"https://api.github.com/users/haleemur/events{/privacy}","received_events_url":"https://api.github.com/users/haleemur/received_events","type":"User","site_admin":false},"body":"Pull request to solve Issue: [Fix DELETE statement for Redshift Dialect](https://github.com/graingert/redshift_sqlalchemy/issues/35).\r\n\r\nAdds support so that the following sqlalchemy query\r\n\r\n    stmt = delete(table1).where(table1.c.id==table2.c.id)\r\n\r\nis compiled as \r\n\r\n    DELETE FROM table1\r\n    USING table2\r\n    WHERE table1.id = table2.id\r\n\r\ninstead of \r\n\r\n    DELETE FROM table1\r\n    WHERE table1.id = table2.id\r\n","created_at":"2015-09-02T14:51:39Z","updated_at":"2015-09-02T18:37:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"68fa26904d0492a449ad65fdbd0bc5bd241ab2e8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/pulls/36/commits","review_comments_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/pulls/36/comments","review_comment_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/issues/36/comments","statuses_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/statuses/1d7040ba063d5c4ba3e879b74f26e8db7a4cfca3","head":{"label":"haleemur:fix_redshift_delete_stmt","ref":"fix_redshift_delete_stmt","sha":"1d7040ba063d5c4ba3e879b74f26e8db7a4cfca3","user":{"login":"haleemur","id":6108231,"avatar_url":"https://avatars.githubusercontent.com/u/6108231?v=3","gravatar_id":"","url":"https://api.github.com/users/haleemur","html_url":"https://github.com/haleemur","followers_url":"https://api.github.com/users/haleemur/followers","following_url":"https://api.github.com/users/haleemur/following{/other_user}","gists_url":"https://api.github.com/users/haleemur/gists{/gist_id}","starred_url":"https://api.github.com/users/haleemur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haleemur/subscriptions","organizations_url":"https://api.github.com/users/haleemur/orgs","repos_url":"https://api.github.com/users/haleemur/repos","events_url":"https://api.github.com/users/haleemur/events{/privacy}","received_events_url":"https://api.github.com/users/haleemur/received_events","type":"User","site_admin":false},"repo":{"id":41505263,"name":"redshift_sqlalchemy","full_name":"haleemur/redshift_sqlalchemy","owner":{"login":"haleemur","id":6108231,"avatar_url":"https://avatars.githubusercontent.com/u/6108231?v=3","gravatar_id":"","url":"https://api.github.com/users/haleemur","html_url":"https://github.com/haleemur","followers_url":"https://api.github.com/users/haleemur/followers","following_url":"https://api.github.com/users/haleemur/following{/other_user}","gists_url":"https://api.github.com/users/haleemur/gists{/gist_id}","starred_url":"https://api.github.com/users/haleemur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haleemur/subscriptions","organizations_url":"https://api.github.com/users/haleemur/orgs","repos_url":"https://api.github.com/users/haleemur/repos","events_url":"https://api.github.com/users/haleemur/events{/privacy}","received_events_url":"https://api.github.com/users/haleemur/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/haleemur/redshift_sqlalchemy","description":"Amazon Redshift SQLAlchemy Dialect","fork":true,"url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy","forks_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/forks","keys_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/teams","hooks_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/hooks","issue_events_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/issues/events{/number}","events_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/events","assignees_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/assignees{/user}","branches_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/branches{/branch}","tags_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/tags","blobs_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/git/refs{/sha}","trees_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/statuses/{sha}","languages_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/languages","stargazers_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/stargazers","contributors_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/contributors","subscribers_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/subscribers","subscription_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/subscription","commits_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/commits{/sha}","git_commits_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/git/commits{/sha}","comments_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/comments{/number}","issue_comment_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/issues/comments{/number}","contents_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/contents/{+path}","compare_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/merges","archive_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/downloads","issues_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/issues{/number}","pulls_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/pulls{/number}","milestones_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/milestones{/number}","notifications_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/labels{/name}","releases_url":"https://api.github.com/repos/haleemur/redshift_sqlalchemy/releases{/id}","created_at":"2015-08-27T18:53:25Z","updated_at":"2015-08-27T18:53:26Z","pushed_at":"2015-09-02T15:00:08Z","git_url":"git://github.com/haleemur/redshift_sqlalchemy.git","ssh_url":"git@github.com:haleemur/redshift_sqlalchemy.git","clone_url":"https://github.com/haleemur/redshift_sqlalchemy.git","svn_url":"https://github.com/haleemur/redshift_sqlalchemy","homepage":null,"size":275,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"graingert:master","ref":"master","sha":"be53c70fbf5ac6e25175e5a7642e08111d00b32d","user":{"login":"graingert","id":413772,"avatar_url":"https://avatars.githubusercontent.com/u/413772?v=3","gravatar_id":"","url":"https://api.github.com/users/graingert","html_url":"https://github.com/graingert","followers_url":"https://api.github.com/users/graingert/followers","following_url":"https://api.github.com/users/graingert/following{/other_user}","gists_url":"https://api.github.com/users/graingert/gists{/gist_id}","starred_url":"https://api.github.com/users/graingert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/graingert/subscriptions","organizations_url":"https://api.github.com/users/graingert/orgs","repos_url":"https://api.github.com/users/graingert/repos","events_url":"https://api.github.com/users/graingert/events{/privacy}","received_events_url":"https://api.github.com/users/graingert/received_events","type":"User","site_admin":false},"repo":{"id":35280897,"name":"redshift_sqlalchemy","full_name":"graingert/redshift_sqlalchemy","owner":{"login":"graingert","id":413772,"avatar_url":"https://avatars.githubusercontent.com/u/413772?v=3","gravatar_id":"","url":"https://api.github.com/users/graingert","html_url":"https://github.com/graingert","followers_url":"https://api.github.com/users/graingert/followers","following_url":"https://api.github.com/users/graingert/following{/other_user}","gists_url":"https://api.github.com/users/graingert/gists{/gist_id}","starred_url":"https://api.github.com/users/graingert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/graingert/subscriptions","organizations_url":"https://api.github.com/users/graingert/orgs","repos_url":"https://api.github.com/users/graingert/repos","events_url":"https://api.github.com/users/graingert/events{/privacy}","received_events_url":"https://api.github.com/users/graingert/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/graingert/redshift_sqlalchemy","description":"Amazon Redshift SQLAlchemy Dialect","fork":true,"url":"https://api.github.com/repos/graingert/redshift_sqlalchemy","forks_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/forks","keys_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/teams","hooks_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/hooks","issue_events_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/issues/events{/number}","events_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/events","assignees_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/assignees{/user}","branches_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/branches{/branch}","tags_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/tags","blobs_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/git/refs{/sha}","trees_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/statuses/{sha}","languages_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/languages","stargazers_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/stargazers","contributors_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/contributors","subscribers_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/subscribers","subscription_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/subscription","commits_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/commits{/sha}","git_commits_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/git/commits{/sha}","comments_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/comments{/number}","issue_comment_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/issues/comments{/number}","contents_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/contents/{+path}","compare_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/merges","archive_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/downloads","issues_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/issues{/number}","pulls_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/pulls{/number}","milestones_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/milestones{/number}","notifications_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/labels{/name}","releases_url":"https://api.github.com/repos/graingert/redshift_sqlalchemy/releases{/id}","created_at":"2015-05-08T13:29:24Z","updated_at":"2015-08-25T20:16:20Z","pushed_at":"2015-09-02T15:00:09Z","git_url":"git://github.com/graingert/redshift_sqlalchemy.git","ssh_url":"git@github.com:graingert/redshift_sqlalchemy.git","clone_url":"https://github.com/graingert/redshift_sqlalchemy.git","svn_url":"https://github.com/graingert/redshift_sqlalchemy","homepage":null,"size":734,"stargazers_count":4,"watchers_count":4,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":8,"forks":3,"open_issues":8,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/graingert/redshift_sqlalchemy/pulls/36"},"html":{"href":"https://github.com/graingert/redshift_sqlalchemy/pull/36"},"issue":{"href":"https://api.github.com/repos/graingert/redshift_sqlalchemy/issues/36"},"comments":{"href":"https://api.github.com/repos/graingert/redshift_sqlalchemy/issues/36/comments"},"review_comments":{"href":"https://api.github.com/repos/graingert/redshift_sqlalchemy/pulls/36/comments"},"review_comment":{"href":"https://api.github.com/repos/graingert/redshift_sqlalchemy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/graingert/redshift_sqlalchemy/pulls/36/commits"},"statuses":{"href":"https://api.github.com/repos/graingert/redshift_sqlalchemy/statuses/1d7040ba063d5c4ba3e879b74f26e8db7a4cfca3"}}}}