Skip to content

Commit 3d27889

Browse files
committed
[postgres] sync extract_value_from_default with AR
1 parent 135b4e2 commit 3d27889

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/arjdbc/postgresql/column.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def extract_limit(sql_type) # :nodoc:
1515
end
1616

1717
# Extracts the value from a PostgreSQL column default definition.
18-
def extract_value_from_default(default) # :nodoc:
18+
def extract_value_from_default(default)
1919
case default
2020
# Quoted types
2121
when /\A[\(B]?'(.*)'.*::"?([\w. ]+)"?(?:\[\])?\z/m
@@ -41,10 +41,13 @@ def extract_value_from_default(default) # :nodoc:
4141
end
4242
end
4343

44-
def extract_default_function(default_value, default) # :nodoc:
45-
default if ! default_value && ( %r{\w+\(.*\)|\(.*\)::\w+} === default )
44+
def extract_default_function(default_value, default)
45+
default if has_default_function?(default_value, default)
4646
end
4747

48+
def has_default_function?(default_value, default)
49+
!default_value && %r{\w+\(.*\)|\(.*\)::\w+|CURRENT_DATE|CURRENT_TIMESTAMP} === default
50+
end
4851
end
4952

5053
end

0 commit comments

Comments
 (0)