Skip to content

Commit

Permalink
Merge branch 'main' into version-2
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdan committed Nov 13, 2024
2 parents ee983ff + e7a8bb8 commit a171ba7
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/datagrid/drivers/abstract_driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def reverse_order(scope)
raise NotImplementedError
end

def is_timestamp?(scope, field)
def timestamp_column?(scope, field)
normalized_column_type(scope, field) == :timestamp
end

Expand Down
2 changes: 1 addition & 1 deletion lib/datagrid/drivers/mongo_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def scope_has_column?(scope, column_name)
scope.key?(column_name)
end

def is_timestamp?(_scope, _column_name)
def timestamp_column?(_scope, _column_name)
# TODO: implement the support
false
end
Expand Down
2 changes: 1 addition & 1 deletion lib/datagrid/filters/date_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def format(value)
end

def default_filter_where(scope, value)
value = Datagrid::Utils.format_date_as_timestamp(value) if driver.is_timestamp?(scope, name)
value = Datagrid::Utils.format_date_as_timestamp(value) if driver.timestamp_column?(scope, name)
super
end

Expand Down
2 changes: 1 addition & 1 deletion lib/datagrid/filters/dynamic_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def default_filter_where(scope, filter)
field = filter.field
operation = filter.operation
value = filter.value
date_conversion = value.is_a?(Date) && driver.is_timestamp?(scope, field)
date_conversion = value.is_a?(Date) && driver.timestamp_column?(scope, field)

return scope if field.blank? || operation.blank?

Expand Down
1 change: 1 addition & 0 deletions lib/datagrid/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def parse_datetime(value)
Array(Datagrid.configuration.datetime_formats).each do |format|
return Time.strptime(value, format)
rescue ::ArgumentError
nil
end
end
return Time.parse(value) if value.is_a?(String)
Expand Down
6 changes: 3 additions & 3 deletions spec/datagrid/filters_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -298,16 +298,16 @@ class TestGrid8728 < Datagrid::Base
end

context "with delegation to attribute" do
let(:role) { Struct.new(:admin?).new(admin) }
let(:role) { Struct.new(:admin).new(admin) }
let(:klass) do
test_report_class do
attr_accessor :role

delegate :admin?, to: :role
delegate :admin, to: :role

scope { Entry }

filter(:id, :integer, if: :admin?)
filter(:id, :integer, if: :admin)
end
end

Expand Down

0 comments on commit a171ba7

Please sign in to comment.