Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #283 from Dynamoid/fix-table-creation
Fix table creation
- Loading branch information
Showing
11 changed files
with
407 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,5 +73,7 @@ def initialize(document) | |
end | ||
|
||
class InvalidQuery < Error; end | ||
|
||
class UnsupportedKeyType < Error; end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# frozen_string_literal: true | ||
|
||
module Dynamoid | ||
class PrimaryKeyTypeMapping | ||
def self.dynamodb_type(type, options) | ||
if Class === type | ||
type = type.respond_to?(:dynamoid_field_type) ? type.dynamoid_field_type : :string | ||
end | ||
|
||
case type | ||
when :string, :serialized | ||
:string | ||
when :integer, :number | ||
:number | ||
when :datetime | ||
string_format = if options[:store_as_string].nil? | ||
Dynamoid::Config.store_datetime_as_string | ||
else | ||
options[:store_as_string] | ||
end | ||
string_format ? :string : :number | ||
when :date | ||
string_format = if options[:store_as_string].nil? | ||
Dynamoid::Config.store_date_as_string | ||
else | ||
options[:store_as_string] | ||
end | ||
string_format ? :string : :number | ||
else | ||
raise Errors::UnsupportedKeyType, "#{type} cannot be used as a type of table key attribute" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.