@@ -33,12 +33,12 @@ setGeneric("pqListTables",
33
33
# ' @rdname pqListTables
34
34
# ' @export
35
35
setMethod ("pqListTables ", "PqConnection", function(conn) {
36
- query <- list_tables_sql(conn = conn )
36
+ query <- list_tables_sql(conn = conn , order_by = " cl.relkind, cl.relname " )
37
37
38
38
dbGetQuery(conn , query )[[" relname" ]]
39
39
})
40
40
41
- list_tables_sql <- function (conn , where_schema = NULL ) {
41
+ list_tables_sql <- function (conn , where_schema = NULL , order_by = NULL ) {
42
42
major_server_version <- dbGetInfo(conn )$ db.version %/% 10000
43
43
44
44
query <- paste0(
@@ -82,10 +82,7 @@ list_tables_sql <- function(conn, where_schema = NULL) {
82
82
query <- paste0(query , where_schema )
83
83
}
84
84
85
- query <- paste0(
86
- query ,
87
- " ORDER BY cl.relkind, cl.relname"
88
- )
85
+ if (! is.null(order_by )) query <- paste0(query , " ORDER BY " , order_by )
89
86
90
87
query
91
88
}
@@ -129,7 +126,7 @@ setGeneric("pqListObjects",
129
126
setMethod ("pqListObjects ", c("PqConnection", "ANY"), function(conn, prefix = NULL, ...) {
130
127
query <- NULL
131
128
if (is.null(prefix )) {
132
- query <- list_tables_sql(conn = conn )
129
+ query <- list_tables_sql(conn = conn , order_by = " cl.relkind, cl.relname " )
133
130
query <- paste0(
134
131
" SELECT NULL AS schema, relname AS table FROM ( \n " ,
135
132
query ,
@@ -150,7 +147,12 @@ setMethod("pqListObjects", c("PqConnection", "ANY"), function(conn, prefix = NUL
150
147
paste(schema_strings , collapse = " , " ),
151
148
" )"
152
149
)
153
- query <- list_tables_sql(conn = conn , where_schema = where_schema )
150
+ query <-
151
+ list_tables_sql(
152
+ conn = conn ,
153
+ where_schema = where_schema ,
154
+ order_by = " cl.relkind, cl.relname"
155
+ )
154
156
query <- paste0(
155
157
" SELECT nspname AS schema, relname AS table FROM ( \n " ,
156
158
query ,
0 commit comments