R/ExprIsNotNull.R

#' This class represents the IS NOT NULL test.
#'
#' Used to test if a field is NOT NULL inside a WHERE clause.
#'
#' @examples
#' # To generate a NOT NULL test:
#' ExprIsNotNull$new(ExprField$new("title"))
#'
#' @import R6
#' @include ExprComp.R
#' @export
ExprIsNotNull <- R6::R6Class("ExprIsNotNull",
  inherit = ExprComp,
  public = list(

    #' @description
    #' Initializer.
    #' @param expr The Expr instance to test.
    #' @param ... Arguments to pass to parent class.
    #' @return Nothing.
    initialize = function(expr, ...) {
      super$initialize(...)
      chk::chk_is(expr, "Expr")
      private$expr <- expr

      return(invisible(NULL))
    },

    #' @description
    #' Generates the list of tokens representing this statement.
    #' @return A list of Token objects.
    getTokens = function() {
      tokens <- list()
      if (private$paren) {
        tokens <- c(tokens, .lparen)
      }
      tokens <- c(tokens, private$expr$getTokens(), .spc, .is, .spc, .not,
                  .spc, .null)
      if (private$paren) {
        tokens <- c(tokens, .rparen)
      }
      return(tokens)
    }
  ),
  private = list(
    expr = NULL
  )
)

Try the sqlq package in your browser

Any scripts or data that you put into this service are public.

sqlq documentation built on Sept. 16, 2025, 9:10 a.m.