Skip to content

Instantly share code, notes, and snippets.

@yuvadm
Created September 24, 2014 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuvadm/08227e1a8bd0d4e6cdf9 to your computer and use it in GitHub Desktop.
Save yuvadm/08227e1a8bd0d4e6cdf9 to your computer and use it in GitHub Desktop.
07:20 <yuvadm> i think we have a time zone diff here :) let's try this async'ly
07:22 <yuvadm> I think the relevant function here is add_field in the BaseSchemaEditor
07:24 <yuvadm> the right thing to do, i guess, is to edit the field.default directly, since it's just a field clone?
07:24 <yuvadm> (somewhere around line 422)
07:24 <yuvadm> or is there a better way to to this?
17:42 <andrewgodwin> I think the best way is to modify "effective_default"
17:42 <andrewgodwin> that's the function that's already there for the purpose of returning defaults that aren't exactly what their field says
19:53 <yuvadm> awesome i'll try that, thanks!
19:54 <yuvadm> i also added a unit test, but i failed to actually get it to fail
19:55 <yuvadm> any thoughts on what i should be asserting?
19:55 <yuvadm> i think i tried asserting something on the migration action.field.default
19:55 <andrewgodwin> You want to try adding a null=False field to a table with data in it
19:55 <andrewgodwin> under Postgres
19:55 <andrewgodwin> that checks the actual result
19:56 <yuvadm> will do that, thanks for the pointers :)
19:57 <andrewgodwin> it won't fail under sqlite, but since you're testing it always works, the one test will be fine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment