Giter VIP home page Giter VIP logo

dm-is-list's People

Contributors

be9 avatar bernerdschaefer avatar dkubb avatar gix avatar kematzy avatar michaelklishin avatar myabc avatar namelessjon avatar paul avatar sam avatar snusnu avatar solnic avatar somebee avatar tpitale avatar xaviershay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

dm-is-list's Issues

Saving Null Values

Greetings,

I have the following models, and I am using dm-is-list to sort them:

class Section
        include DataMapper::Resource

        property :id, Serial
        property :name, String, :length => 1..100
        property :credits, String, :length => 1..10

        has n, :courses, :through => Resource

        is :list, :scope => [:program_id]
    end

    class Course
        include DataMapper::Resource

        property :id, Serial
        property :subj, String, :length => 4
        property :code, String, :length => 3..5
        property :name, String, :length => 1..100
        property :description, Text
        property :credits, String, :length => 1..10

        has n, :sections, :through => Resource

    end

    class CourseSection
        include DataMapper::Resource

        belongs_to :course, :key => true
        belongs_to :section, :key => true

        is :list, :scope => [:section_id]
    end

I am unable to select a given course and move it, so I am moving the Course Sections. I can use CourseSection.move(position) without issue. My problem gets more complicated when I try to use move_to_list(sectionID, position).

dm-is-list is setting the position value to NULL (I have verified that position is being sent). I have even tried to use move_to_list(sectionID) with no position, and NULL is still saved to the database. Obviously, subsequent attempts to move the item after that fail.

I attempted to define the position property as not null but that just resulted in an error when it tried to save the null. Position should never be null. This is making the gem unusable for me at this time.

`move :below` fails

test case: https://github.com/FND/dm-is-list/compare/below_bug

the first .move :below fails - yet it succeeds if first doing an arbitrary .move :above

Since the RSpec test case seems potentially confusing, here's a sample script that might make it clearer:

module DEBUG

  def self.info
    puts Animal.all(:order => :position.asc).map(&:id).join("  ")
  end

  def self.move(id, vector, ref_id)
    puts Animal.get!(id).move vector => Animal.get!(ref_id)
  end

end

5.times do |i|
  name = "animal#{i}"
  Animal.create
end

DEBUG::info # 1  2  3  4  5
DEBUG::move 5, :below, 1 # false
DEBUG::info # 1  2  3  4  5
DEBUG::move 5, :above, 1 # true
DEBUG::info # 5  1  2  3  4
DEBUG::move 5, :below, 1 # true
DEBUG::info # 1  5  2  3  4

inherited class method does not exist

When I tried use dm-is-list with datamapper 1.3.0beta I error message with inherited hook.

Below I past part of necessary error message:

/.../gems/dm-core-f51603618654/lib/dm-core/support/hook.rb:169:in register_hook': inherited class method does not exist (ArgumentError) from /.../gems/dm-core-f51603618654/lib/dm-core/support/hook.rb:353:ininstall_hook'
from /.../gems/dm-core-f51603618654/lib/dm-core/support/hook.rb:72:in after_class_method' from /.../gems/1.9.1/bundler/gems/dm-is-list-6826cd2647bf/lib/dm-is-list/is/list.rb:297:inis_list'

Indexed position field

Since the position field will probably be constantly used for ordering, it might be nice to change the property definition to
property :position, Integer, :index => true

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.