Ok, I just noticed something REALLY weird. The error isn't occurring when creating this list of table pointers. It occurs only when printing the table pointers as a list by referencing the list itself by name.
table_names <- glue("flights_{1:2}")
table_list <- table_names %>%
map(., .f = ~tbl(con, .x))
table_list[[1]]
#> # Source: table<flights_1> [?? x 19]
#> # Database: Microsoft SQL Server
#> # 12.00.5203[dbo@MS_SQL_Server_12/my_Database]
#> year month day dep_time sched_dep_time dep_delay arr_time
#> <int> <int> <int> <int> <int> <dbl> <int>
#> 1 2013 1 1 517 515 2 830
#> 2 2013 1 1 533 529 4 850
#> 3 2013 1 1 542 540 2 923
#> 4 2013 1 1 544 545 -1 1004
#> 5 2013 1 1 554 600 -6 812
#> 6 2013 1 1 554 558 -4 740
#> 7 2013 1 1 555 600 -5 913
#> 8 2013 1 1 557 600 -3 709
#> 9 2013 1 1 557 600 -3 838
#> 10 2013 1 1 558 600 -2 753
#> # ... with more rows, and 12 more variables: sched_arr_time <int>,
#> # arr_delay <dbl>, carrier <chr>, flight <int>, tailnum <chr>,
#> # origin <chr>, dest <chr>, air_time <dbl>, distance <dbl>,
#> # hour <dbl>, minute <dbl>, time_hour <dttm>
So this works great, right?
EXCEPT, when I try to print it as the list that I've created, table_list, I get the error as before. And after having done that once, I can't refer to a single table pointer in the list without getting an error.
> table_list
#> [[1]]
#> Error: <SQL> 'SELECT TOP 10 *
#> FROM "flights_1"'
#> nanodbc/nanodbc.cpp:1587: 42S02: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Invalid object name 'flights_1'.
> table_list[[1]]
#> Error: <SQL> 'SELECT TOP 10 *
#> FROM "flights_1"'
#> nanodbc/nanodbc.cpp:1587: 42S02: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Invalid object name 'flights_1'.
So now, something that worked fine (referring to the element in the list), literally just a couple of seconds ago, doesn't work anymore once I've tried to print the list once.
This is the structure of the list.
> str(table_list)
List of 2
$ :List of 2
..$ src:List of 2
.. ..$ con :Formal class 'Microsoft SQL Server' [package ".GlobalEnv"] with 4 slots
.. .. .. ..@ ptr :<externalptr>
.. .. .. ..@ quote : chr "\""
.. .. .. ..@ info :List of 13
.. .. .. .. ..$ dbname : chr "my_Database"
.. .. .. .. ..$ dbms.name : chr "Microsoft SQL Server"
.. .. .. .. ..$ db.version : chr "12.00.5203"
.. .. .. .. ..$ username : chr "dbo"
.. .. .. .. ..$ host : chr ""
.. .. .. .. ..$ port : chr ""
.. .. .. .. ..$ sourcename : chr "MS_SQL_Server_12"
.. .. .. .. ..$ servername : chr "MS_SQL_Server_12\\SERVER"
.. .. .. .. ..$ drivername : chr "msodbcsql13.dll"
.. .. .. .. ..$ odbc.version : chr "03.80.0000"
.. .. .. .. ..$ driver.version : chr "14.00.1000"
.. .. .. .. ..$ odbcdriver.version : chr "03.80"
.. .. .. .. ..$ supports.transactions: logi TRUE
.. .. .. .. ..- attr(*, "class")= chr [1:3] "Microsoft SQL Server" "driver_info" "list"
.. .. .. ..@ encoding: chr ""
.. ..$ disco: NULL
.. ..- attr(*, "class")= chr [1:3] "src_dbi" "src_sql" "src"
..$ ops:List of 2
.. ..$ x : 'ident' chr "flights_1"
.. ..$ vars: chr [1:19] "year" "month" "day" "dep_time" ...
.. ..- attr(*, "class")= chr [1:3] "op_base_remote" "op_base" "op"
..- attr(*, "class")= chr [1:4] "tbl_dbi" "tbl_sql" "tbl_lazy" "tbl"
$ :List of 2
..$ src:List of 2
.. ..$ con :Formal class 'Microsoft SQL Server' [package ".GlobalEnv"] with 4 slots
.. .. .. ..@ ptr :<externalptr>
.. .. .. ..@ quote : chr "\""
.. .. .. ..@ info :List of 13
.. .. .. .. ..$ dbname : chr "my_Database"
.. .. .. .. ..$ dbms.name : chr "Microsoft SQL Server"
.. .. .. .. ..$ db.version : chr "12.00.5203"
.. .. .. .. ..$ username : chr "dbo"
.. .. .. .. ..$ host : chr ""
.. .. .. .. ..$ port : chr ""
.. .. .. .. ..$ sourcename : chr "MS_SQL_Server_12"
.. .. .. .. ..$ servername : chr "MS_SQL_Server_12\\SERVER"
.. .. .. .. ..$ drivername : chr "msodbcsql13.dll"
.. .. .. .. ..$ odbc.version : chr "03.80.0000"
.. .. .. .. ..$ driver.version : chr "14.00.1000"
.. .. .. .. ..$ odbcdriver.version : chr "03.80"
.. .. .. .. ..$ supports.transactions: logi TRUE
.. .. .. .. ..- attr(*, "class")= chr [1:3] "Microsoft SQL Server" "driver_info" "list"
.. .. .. ..@ encoding: chr ""
.. ..$ disco: NULL
.. ..- attr(*, "class")= chr [1:3] "src_dbi" "src_sql" "src"
..$ ops:List of 2
.. ..$ x : 'ident' chr "flights_2"
.. ..$ vars: chr [1:19] "year" "month" "day" "dep_time" ...
.. ..- attr(*, "class")= chr [1:3] "op_base_remote" "op_base" "op"
..- attr(*, "class")= chr [1:4] "tbl_dbi" "tbl_sql" "tbl_lazy" "tbl"
But then when I try to print the list, as mentioned, the error comes up and after that I can't even refer to a single pointer in said list. However the structure of the list is 100% unchanged.
This feels veeeeeery strange to me.