Skip to content

Commit 969902c

Browse files
author
Bulat Shakirzyanov
committed
don't blow up on custom types
1 parent fff7e15 commit 969902c

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/cassandra/cluster/schema/type_parser.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def lookup_type(node)
108108
return lookup_type(node.children.first)
109109
end
110110

111-
type = @@types[node.name]
111+
type = @@types.fetch(node.name) { return Cassandra::Types.custom(dump_node(node)) }
112112

113113
case type
114114
when :set, :list
@@ -159,6 +159,12 @@ def parse_node(string)
159159

160160
root
161161
end
162+
163+
def dump_node(node)
164+
str = node.name
165+
str << '(' + node.children.map {|n| dump_node(n)}.join(',') + ')' unless node.children.empty?
166+
str
167+
end
162168
end
163169
end
164170
end

lib/cassandra/types.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,7 @@ def assert(value, message = nil, &block)
11991199

12001200
# @return [String] a cassandra representation of this type
12011201
def to_s
1202-
"custom: #{@name}"
1202+
"'#{@name}'"
12031203
end
12041204
end
12051205

0 commit comments

Comments
 (0)