Skip to content

Commit f16ca36

Browse files
committed
generic (jdbc adapter) JDBC API impl for supports_views?
1 parent 74412e7 commit f16ca36

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

lib/arjdbc/jdbc/adapter.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,11 @@ def current_savepoint_name(create = nil)
418418
end
419419
end
420420

421+
# @override
422+
def supports_views?
423+
@connection.supports_views?
424+
end
425+
421426
# Executes a SQL query in the context of this connection using the bind
422427
# substitutes.
423428
# @param sql the query string (or AREL object)

src/java/arjdbc/jdbc/RubyJdbcConnection.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,6 +1226,27 @@ runtime, caseConvertIdentifierForRails(metaData, columnName)
12261226
});
12271227
}
12281228

1229+
@JRubyMethod(name = "supports_views?")
1230+
public IRubyObject supports_views_p(final ThreadContext context) throws SQLException {
1231+
return withConnection(context, new Callable<IRubyObject>() {
1232+
public IRubyObject call(final Connection connection) throws SQLException {
1233+
final DatabaseMetaData metaData = connection.getMetaData();
1234+
final ResultSet tableTypes = metaData.getTableTypes();
1235+
try {
1236+
while ( tableTypes.next() ) {
1237+
if ( "VIEW".equalsIgnoreCase( tableTypes.getString(1) ) ) {
1238+
return context.getRuntime().newBoolean( true );
1239+
}
1240+
}
1241+
}
1242+
finally {
1243+
close(tableTypes);
1244+
}
1245+
return context.getRuntime().newBoolean( false );
1246+
}
1247+
});
1248+
}
1249+
12291250
// NOTE: this seems to be not used ... at all ?!
12301251
/*
12311252
* sql, values (array), types (column.type array), name = nil, pk = nil, id_value = nil, sequence_name = nil

0 commit comments

Comments
 (0)