-------------------------------------------------------------------------------- -- Title: DBSQLSelect.lua -- Description: Like a square peg in a round hole -- Author: Raphaël Szwarc http://alt.textdrive.com/lua/ -- Creation Date: February 1, 2005 -- Legal: Copyright (C) 2005 Raphaël Szwarc -------------------------------------------------------------------------------- -- import dependencies local DBSQLExpression = require( "DBSQLExpression" ) local LUList = require( "LUList" ) -- define the class local super = DBSQLExpression local self = super() function self:name() return "select" end function self:ordering() return self._ordering end function self:setOrdering( aValue ) self._ordering = aValue return self end function self:toString() local aBuffer = LUList() local aName = self:name() local someKeys = self:dbKeys() local aTarget = self:dbTarget() local aWhere = self:where() local anOrdering = self:ordering() aBuffer:add( aName ) if someKeys:hasData() == true then aBuffer:add( someKeys:join( ", " ) ) else aBuffer:add( "*" ) end aBuffer:add( "from" ) aBuffer:add( aTarget ) if aWhere ~= nil then aBuffer:add( "where" ) aBuffer:add( aWhere:toString( self ) ) end if anOrdering ~= nil then aBuffer:add( anOrdering:toString( self ) ) end return aBuffer:join( " " ) end return self