new (DataMapper::Query)

    # File lib/dm-core/query.rb, line 585
        def initialize(repository, model, options = {})
          assert_kind_of 'repository', repository, Repository
          assert_kind_of 'model',      model,      Model

          @repository = repository
          @model      = model
          @options    = options.dup.freeze

          repository_name = repository.name

          @properties    = @model.properties(repository_name)
          @relationships = @model.relationships(repository_name)

          assert_valid_options(@options)

          @fields       = @options.fetch :fields,       @properties.defaults
          @links        = @options.fetch :links,        []
          @conditions   = Conditions::Operation.new(:null)
          @offset       = @options.fetch :offset,       0
          @limit        = @options.fetch :limit,        nil
          @order        = @options.fetch :order,        @model.default_order(repository_name)
          @unique       = @options.fetch :unique,       false
          @add_reversed = @options.fetch :add_reversed, false
          @reload       = @options.fetch :reload,       false
          @raw          = false

          @links = @links.dup

          # treat all non-options as conditions
          @options.except(*OPTIONS).each { |kv| append_condition(*kv) }

          # parse @options[:conditions] differently
          case conditions = @options[:conditions]
            when Conditions::AbstractOperation, Conditions::AbstractComparison
              add_condition(conditions)

            when Hash
              conditions.each { |kv| append_condition(*kv) }

            when Array
              statement, *bind_values = *conditions
              add_condition([ statement, bind_values ])
              @raw = true
          end

          normalize_order
          normalize_fields
          normalize_links
        end