def test_add(self): results = list( DynamicModel.objects.annotate( attrs2=ColumnAdd('attrs', {'another': 'key'})).values_list( 'attrs2', flat=True)) assert results == [{ 'flote': 1.0, 'sub': { 'document': 'store' }, 'another': 'key' }]
def test_add(self): results = list( DynamicModel.objects.annotate( attrs2=ColumnAdd("attrs", {"another": "key"})).values_list( "attrs2", flat=True)) assert results == [{ "flote": 1.0, "sub": { "document": "store" }, "another": "key" }]
def set_isdefaultbrowser_clientoption(apps, schema_editor): Snippet = apps.get_model('base', 'Snippet') Snippet.objects.update(client_options=ColumnAdd( 'client_options', {'is_default_browser': AsType('any', 'CHAR')}))
def set_default_bounds_for_sessionage(apps, schema_editor): Snippet = apps.get_model('base', 'Snippet') Snippet.objects.update(client_options=ColumnAdd( 'client_options', {'sessionage_lower_bound': AsType(-1, 'INTEGER')})) Snippet.objects.update(client_options=ColumnAdd( 'client_options', {'sessionage_upper_bound': AsType(-1, 'INTEGER')}))
def test_add_update(self): DynamicModel.objects.update(attrs=ColumnAdd("attrs", {"over": 9000})) m = DynamicModel.objects.get() assert m.attrs == {"flote": 1.0, "sub": {"document": "store"}, "over": 9000}
def set_default_resolutions(apps, schema_editor): Snippet = apps.get_model('base', 'Snippet') resolutions = '0-1024;1024-1920;1920-50000' Snippet.objects.update(client_options=ColumnAdd( 'client_options', {'screen_resolutions': AsType(resolutions, 'CHAR')}))
def set_has_testpilot(apps, schema_editor): Snippet = apps.get_model('base', 'Snippet') Snippet.objects.update(client_options=ColumnAdd( 'client_options', {'has_testpilot': AsType('any', 'CHAR')}))
def migrate_aboutaccounts_snippets(apps, schema_editor): """Migrate existing snippets that used about:accounts link filtering.""" Snippet = apps.get_model('base', 'Snippet') Snippet.objects.update(client_options=ColumnAdd( 'client_options', {'has_testpilot': AsType('any', 'CHAR')}))
def test_add_update_typed(self): DynamicModel.objects.update( attrs=ColumnAdd("attrs", {"over": AsType(9000, "DOUBLE")})) m = DynamicModel.objects.get() assert isinstance(m.attrs["over"], float) assert m.attrs["over"] == 9000.0
def test_add_update_typed(self): DynamicModel.objects.update(attrs=ColumnAdd( 'attrs', {'over': AsType(9000, 'DOUBLE')}), ) m = DynamicModel.objects.get() assert isinstance(m.attrs['over'], float) assert m.attrs['over'] == 9000.0
def test_add_update_typed_expressions(self): DynamicModel.objects.update(attrs=ColumnAdd( "attrs", {Value("over"): AsType(Value(9000), "DOUBLE")})) m = DynamicModel.objects.get() assert isinstance(m.attrs["over"], float) assert m.attrs["over"] == 9000.0