1. anatoly techtonik
  2. pypi-techtonik

Commits

Martin von Löwis  committed 1c94ae7

Rename "user" to "user_name" column to prevent conflict with PostgreSQL keyword.
Closes #2 on https://bitbucket.org/loewis/pypi.

  • Participants
  • Parent commits dce1164
  • Branches default

Comments (0)

Files changed (4)

File pkgbase_schema.sql

View file
       consumer              varchar(32) not null,
       callback              text,
       date_created          date not null,
-      user TEXT REFERENCES users ON UPDATE CASCADE ON DELETE CASCADE
+      user_name TEXT REFERENCES users ON UPDATE CASCADE ON DELETE CASCADE
 );
 
 CREATE TABLE oauth_access_tokens (
       consumer              varchar(32) not null,
       date_created          date not null,
       last_modified         date not null,
-      user TEXT REFERENCES users ON UPDATE CASCADE ON DELETE CASCADE
+      user_name TEXT REFERENCES users ON UPDATE CASCADE ON DELETE CASCADE
 );
 
 CREATE TABLE oauth_nonce (

File store.py

View file
         oauth_token is just a string
         user is the username of the account to associate with
         '''
-        sql = 'update oauth_request_tokens set user=%s where token=%s'
+        sql = 'update oauth_request_tokens set user_name=%s where token=%s'
         safe_execute(self.store.get_cursor(), sql, (user, oauth_token))
         # XXX note: no return value. Spec says to return OAuthToken but it's
         # not used and I'd have to do a separate SELECT so I just don't see the
         '''
         # find user in the oauth_request_tokens table
         cursor = self.store.get_cursor()
-        sql = '''select user from oauth_request_tokens
+        sql = '''select user_name from oauth_request_tokens
             where consumer = %s and token = %s'''
         safe_execute(cursor, sql, (oauth_consumer.key, oauth_token.key))
         for row in cursor.fetchall():
 
         # check that there's not already an access token for this consumer / user
         sql = '''select token from oauth_access_tokens
-            where consumer = %s and user = %s'''
+            where consumer = %s and user_name = %s'''
         safe_execute(cursor, sql, (oauth_consumer.key, user))
         for row in cursor.fetchall():
             # return the existing token
 
         # generate the token in the db
         sql = '''insert into oauth_access_tokens
-            (token, secret, consumer, user, date_created, last_modified)
+            (token, secret, consumer, user_name, date_created, last_modified)
             values (%s, %s, %s, %s, %s, %s)'''
         now = datetime.datetime.now()
         safe_execute(cursor, sql, (token, secret, oauth_consumer.key, user,
     def _get_user(self, token):
         '''Given an access token, determine the user associated with it.
         '''
-        sql = 'select user from oauth_access_tokens where token = %s'
+        sql = 'select user_name from oauth_access_tokens where token = %s'
         cursor = self.store.get_cursor()
         safe_execute(cursor, sql, (token.key, ))
         for row in cursor.fetchall():

File tools/sql-migrate-20120314.sql

View file
       consumer              varchar(32) not null,
       callback              text,
       date_created          date not null,
-      user TEXT REFERENCES users ON UPDATE CASCADE ON DELETE CASCADE
+      "user" TEXT REFERENCES users ON UPDATE CASCADE ON DELETE CASCADE
 );
 
 CREATE TABLE oauth_access_tokens (
       consumer              varchar(32) not null,
       date_created          date not null,
       last_modified         date not null,
-      user TEXT REFERENCES users ON UPDATE CASCADE ON DELETE CASCADE
+      "user" TEXT REFERENCES users ON UPDATE CASCADE ON DELETE CASCADE
 );
 
 CREATE TABLE oauth_nonce (

File tools/sql-migrate-20120325.sql

View file
+begin;
+CREATE TABLE oauth_request_tokens2 (
+      token                 varchar(32) primary key,
+      secret                varchar(64) not null,
+      consumer              varchar(32) not null,
+      callback              text,
+      date_created          date not null,
+      user_name TEXT REFERENCES users ON UPDATE CASCADE ON DELETE CASCADE
+);
+
+CREATE TABLE oauth_access_tokens2 (
+      token                 varchar(32) primary key,
+      secret                varchar(64) not null,
+      consumer              varchar(32) not null,
+      date_created          date not null,
+      last_modified         date not null,
+      user_name TEXT REFERENCES users ON UPDATE CASCADE ON DELETE CASCADE
+);
+
+insert into oauth_request_tokens2(token, secret, consumer, 
+              callback, date_created, user_name) 
+select token, secret, consumer, callback, date_created, 
+    user from oauth_request_tokens;
+drop table oauth_request_tokens;
+alter table oauth_request_tokens2 rename to oauth_request_tokens;
+
+insert into oauth_access_tokens2(token, secret, consumer, 
+     date_created, last_modified, user_name) 
+select token, secret, consumer, date_created, last_modified, 
+    user from oauth_access_tokens;
+drop table oauth_access_tokens;
+alter table oauth_access_tokens2 rename to oauth_access_tokens;
+
+end;