Changeset 1483
- Timestamp:
- 11/28/05 19:04:28 (3 years ago)
- Files:
-
- django/trunk/django/core/management.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/core/management.py
r1474 r1483 264 264 get_sql_all.args = APP_ARGS 265 265 266 def has_no_records(cursor): 267 "Returns True if the cursor, having executed a query, returned no records." 268 # This is necessary due to an inconsistency in the DB-API spec. 269 # cursor.rowcount can be -1 (undetermined), according to 270 # http://www.python.org/peps/pep-0249.html 271 if cursor.rowcount < 0: 272 return cursor.fetchone() is None 273 return cursor.rowcount < 1 274 266 275 def database_check(mod): 267 276 "Checks that everything is properly installed in the database for the given module." … … 273 282 cursor.execute("SELECT 1 FROM %s WHERE %s = %%s" % \ 274 283 (db.db.quote_name('packages'), db.db.quote_name('label')), [app_label]) 275 if cursor.rowcount < 1:284 if has_no_records(cursor): 276 285 # sys.stderr.write("The '%s' package isn't installed.\n" % app_label) 277 286 print _get_packages_insert(app_label) … … 289 298 (db.db.quote_name('auth_permissions'), db.db.quote_name('package'), 290 299 db.db.quote_name('codename')), (app_label, codename)) 291 if cursor.rowcount < 1:300 if has_no_records(cursor): 292 301 # sys.stderr.write("The '%s.%s' permission doesn't exist.\n" % (app_label, codename)) 293 302 print _get_permission_insert(name, codename, opts) … … 295 304 (db.db.quote_name('content_types'), db.db.quote_name('package'), 296 305 db.db.quote_name('python_module_name')), (app_label, opts.module_name)) 297 if cursor.rowcount < 1:306 if has_no_records(cursor): 298 307 # sys.stderr.write("The '%s.%s' content type doesn't exist.\n" % (app_label, opts.module_name)) 299 308 print _get_contenttype_insert(opts)
