Coder Social home page Coder Social logo

Comments (6)

john-parton avatar john-parton commented on June 2, 2024

Array fields are cast to python lists. http://docs.python.org/2/tutorial/datastructures.html#more-on-lists
Should work, but haven't tested it: instance.array_prop.remove('some-element')
Remember to call instance.save()

from djorm-pgarray.

john-parton avatar john-parton commented on June 2, 2024

actually, you might need to do something more like this

arr = instance.array_prop
arr.remove('some-element')
instance.array_prop = arr
instance.save()

from djorm-pgarray.

ambasta avatar ambasta commented on June 2, 2024

The issue with the above approach is that editing large arrays becomes very expensive. Modifying an ArrayField with 500,000 elements takes over a second. I was wondering more on the lines if array_append/array_remove/array_replace(http://www.postgresql.org/docs/9.3/static/functions-array.html) etc were available instead.

from djorm-pgarray.

john-parton avatar john-parton commented on June 2, 2024

There's an array that has half a million records in your DB? I'd be curious to know what kind of application needs that kind of scale.

Anyways, I don't think there's anything like this "baked in."

You might take a look at django.db.models.compiler.SQLUpdateCompiler

from djorm-pgarray.

john-parton avatar john-parton commented on June 2, 2024

For now, you might just have to execute the SQL directly: https://docs.djangoproject.com/en/1.6/topics/db/sql/#executing-custom-sql-directly

from djorm-pgarray.

ambasta avatar ambasta commented on June 2, 2024

Figured as much, using raw sql atm.

As for the scale, there are dispatch numbers assigned to a coloader sitting in an arrayfield. Consumption of such a number across any of the few thousand coloading centers is a continous process, at which point it is promptly removed from the arrayfield.

Also thanks for the tip on django.db.models.compiler.SQLUpdateCompiler Will try to see if I can get a patch in.

from djorm-pgarray.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.