Django

Code

Ticket #2729 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

[patch] sqlinitialdata files with dos line endings error out on Gnu/Linux

Reported by: Joeboy Assigned to: adrian
Milestone: Component: Database wrapper
Version: SVN Keywords: sqlinitialdata dos windows
Cc: django25@joebutton.co.uk, dev@simon.net.nz Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

On my Gnu/Linux box, trying to use sqlinitialdata files provided by my windows-using colleagues, I get:

joe@edward ~/reportlab/libs/rltravelprod/djtravel $ ./manage.py reset holidays

You have requested a database reset.
This will IRREVERSIBLY DESTROY any data in your database.
Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: yes
Error: holidays couldn't be installed. Possible reasons:
  * The database isn't running or isn't configured correctly.
  * At least one of the database tables already exists.
  * The SQL was invalid.
Hint: Look at the output of 'django-admin.py sqlreset holidays'. That's the SQL this command wasn't able to run.
The full error: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near ';\r\nINSERT INTO `holidays_resort` (id, name, region_id) VALUES
(2,'Cavtat',1);\r\nI' at line 1")

Converting to unix line endings fixes it.

Attachments

resort.sql (155 bytes) - added by Joeboy on 09/14/06 05:17:53.
sample erroring dos file
2729.diff (0.5 kB) - added by dev@simon.net.nz on 09/15/06 06:27:55.

Change History

09/14/06 05:17:53 changed by Joeboy

  • attachment resort.sql added.

sample erroring dos file

09/14/06 05:18:33 changed by anonymous

  • cc set to django25@joebutton.co.uk.

09/15/06 06:25:05 changed by dev@simon.net.nz

  • cc changed from django25@joebutton.co.uk to django25@joebutton.co.uk, dev@simon.net.nz.
  • summary changed from sqlinitialdata files with dos line endings error out on Gnu/Linux to [patch] sqlinitialdata files with dos line endings error out on Gnu/Linux.

Hmm... using python's "U" mode when reading the file in should fix this by standardising line breaks. I've had a go at this (patch attached), but given that I'm on OSX, I'm not sure that I'm replicating the problem exactly.

09/15/06 06:27:55 changed by dev@simon.net.nz

  • attachment 2729.diff added.

09/25/06 02:36:46 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

(In [3821]) Fixed #2729 -- Handle initial SQL with different line-ending styles (Windows vs. Unix vs. Mac). Thanks, Simon Greenhill.


Add/Change #2729 ([patch] sqlinitialdata files with dos line endings error out on Gnu/Linux)




Change Properties
Action