lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


	Hi Mike

A small addition for dado.sql if you are interested.  Had to add
local pairs = _G.pairs
to get it to work

---------------------------------------------------------------------
-- Builds a string with a JOIN command to be inserted into a SELECT
-- @param tab String containing initial table name
-- @param joins Hash table as tablename = cond
-- @return String to place in select after from
function join(tab, joins)
  local t = tab
  for k, v in pairs(joins) do
    t = t .. " join " .. k .. " on " .. v
  end
  return t
end

	Thanks for the interest, but I am not planning to get
that way since it will sooner or later blow into many variations
like that (innerjoin, leftouterjoin, rightouterjoin...) which will
require more flexibility such as the ability to especify `using'
instead of `on' or even add the table name without a join condition...
	Some time before the development of this library (Dado)
we tried to define all sort of Lua functions and constructors to
help the definition of all SQL.  But we does not succeed in this
effort for various reasons, and now I think it is better to create
just a small set of constructors and some string manipulation
facilities (with some trick you can build the above join using
table.concat).  Anywat, thanks for the suggestion.

	Regards,
		Tomás