Commits

Richard Jones committed f47d523

"fix" sqlite3 handling of timestamp in this one edge case

Comments (0)

Files changed (2)

     example_release(access_token, name='spam', version='3.0', summary='Spam via OAuth',
         description='This package was registered via OAuth.')
 
-    upload = FileUpload(content, filename...)
-    m = hashlib.md5()
-    m.update(content)
-    digest = m.hexdigest()
-    example_upload(access_token, name='spam', version='3.0', summary='Spam via OAuth',
-        description='This package was registered via OAuth.', content=upload,
-        filetype='sdist', md5_digest=digest, comment='via oauth')
+    #upload = FileUpload(content, filename...)
+    #m = hashlib.md5()
+    #m.update(content)
+    #digest = m.hexdigest()
+    #example_upload(access_token, name='spam', version='3.0', summary='Spam via OAuth',
+        #description='This package was registered via OAuth.', content=upload,
+        #filetype='sdist', md5_digest=digest, comment='via oauth')
 
         # table to find the description and whether the package is hidden.
         # Postgres will only do that if the number of expected results
         # is "small".
+
         statement = '''
-            select j.name, r.version, j.submitted_date, r.summary
+            select j.name, r.version, j.submitted_date%s, r.summary
               from releases r
                    JOIN (SELECT name, max(submitted_Date) submitted_date
                          FROM  journals GROUP BY name) j ON j.name = r.name
                and not r._pypi_hidden
                and r.name in (SELECT name FROM journals
                               WHERE  action='create'
-                              ORDER BY submitted_date DESC %s)
+                              ORDER BY submitted_date DESC %%s)
              order by j.submitted_date desc'''
+
+        if self.config.database_driver == 'sqlite3':
+            statement = statement % ' as "sd [timestamp]"'
+        else:
+            statement = statement % ''
+
         #print ' '.join((statement % limit).split())
         safe_execute(cursor, statement % limit)
         result = Result(None, self.get_unique(cursor.fetchall())[:num],
-                self._Latest_Releases)
+                self._Latest_Packages)
         if len(result) == num:
             return result
         # try again without limit
         safe_execute(cursor, statement % '')
         return Result(None, self.get_unique(cursor.fetchall())[:num],
-                self._Latest_Releases)
+                self._Latest_Packages)
 
     _Latest_Releases = FastResultRow('name version submitted_date! summary')
     def latest_releases(self, num=40):
                 return self.open()
         elif self.config.database_driver == 'sqlite3':
             self._conn = connection = sqlite3.connect(self.config.database_name,
-                                                      detect_types=sqlite3.PARSE_DECLTYPES)
+                detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
         else:
             self._conn = connection = psycopg2.connect(**cd)
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.