Class: FluentQuery::Drivers::Shared::Tokens::SQL::Truncate

Inherits:
FluentQuery::Drivers::Shared::Tokens::SQLToken show all
Defined in:
lib/fluent-query/drivers/shared/tokens/sql/truncate.rb

Overview

Generic SQL query TRUNCATE token.

Constant Summary

Constants inherited from FluentQuery::Drivers::Shared::Tokens::SQLToken

FluentQuery::Drivers::Shared::Tokens::SQLToken::TRANSFORMER

Instance Method Summary collapse

Methods inherited from FluentQuery::Drivers::Shared::Tokens::SQLToken

#initialize

Constructor Details

This class inherits a constructor from FluentQuery::Drivers::Shared::Tokens::SQLToken

Instance Method Details

#render!(mode = nil) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fluent-query/drivers/shared/tokens/sql/truncate.rb', line 23

def render!(mode = nil)
    processor = @_query.processor
    result = "TRUNCATE TABLE "

    @_subtokens.each do |token|
        arguments = token.arguments

        # FROM token
        
        if token.name == :truncate

            # Checks for arguments
            if (not arguments.first.symbol?)
                raise FluentQuery::Drivers::Exception::new("Symbol argument expected for #truncate method.")
            end

            # Process
            table = processor.quote_identifier(arguments.first)
            result << table

        # Unknown tokens renders directly
        else
            result << self.unknown_token::new(@_driver, @_query, [token]).render!
        end
        
    end

    result << " CASCADE"
    return result
end