dot-has_column: Check if a column exists in a table (S3 generic)

dot-has_columnR Documentation

Check if a column exists in a table (S3 generic)

Description

Cross-database method to check if a column exists in a table. Uses database-specific introspection methods via S3 dispatch.

Usage

.has_column(conn, table_name, column_name)

## S3 method for class 'SQLiteConnection'
.has_column(conn, table_name, column_name)

## S3 method for class 'PqConnection'
.has_column(conn, table_name, column_name)

## S3 method for class 'MariaDBConnection'
.has_column(conn, table_name, column_name)

## S3 method for class ''Microsoft SQL Server''
.has_column(conn, table_name, column_name)

## S3 method for class 'duckdb_connection'
.has_column(conn, table_name, column_name)

## Default S3 method:
.has_column(conn, table_name, column_name)

Arguments

conn

Database connection (DBIConnection)

table_name

Character. Name of the table

column_name

Character. Name of the column to check

Value

Logical. TRUE if column exists, FALSE otherwise

Functions

  • .has_column(SQLiteConnection): SQLite implementation using PRAGMA

  • .has_column(PqConnection): PostgreSQL implementation using information_schema

  • .has_column(MariaDBConnection): MySQL/MariaDB implementation using information_schema

  • .has_column(`Microsoft SQL Server`): SQL Server implementation using information_schema

  • .has_column(duckdb_connection): DuckDB implementation using information_schema

  • .has_column(default): Default implementation for unknown database types

Examples


if (FALSE) {
conn <- connection_get("my_db")
has_deleted_at <- .has_column(conn, "users", "deleted_at")
DBI::dbDisconnect(conn)
}


framework documentation built on Feb. 18, 2026, 1:07 a.m.