I am making something in Clojure which does SQL at the front end too

27 views
Skip to first unread message

Zubair Quraishi

unread,
Jan 22, 2015, 1:30:30 AM1/22/15
to sql-mv...@googlegroups.com
I am making something in Clojure which does SQL at the front end too, so I am very interested in similar projects, to see if I should continue what I am doing or if I should contribute to another project such as yours. I saw you have posted to try to promote it which is a good thing:


I have a ton on questions:
1) Your background
2) Your motivations to make this project
3) Your aims with this project - commercial / opensource only
4) Could you send me any other links related to your project ?
5) Reeal world apps built with this

Thanks
Zubair Quraishi

Lafras Henning

unread,
Jan 22, 2015, 4:23:14 AM1/22/15
to sql-mv...@googlegroups.com
hi Zubair

1) background - I have been programming since 1983, I have worked on
everything from embedded processors, using assembly through to the
latest which is node.js.

2) motivations - I do things differently than most, I started to
create a web platform
in 1999, using Borland C++Builder (v4), I have used it in many many
custom real world applications,
but it now "old", so this is a rewrite with many new concepts added.
The idea for a single stored procedure came from a 'ah-ha' moment, when
I was comparing the performance
of string concatenation in Firebird SQL stored procedures with that of
python. I can't remember the actual figures but raw concatenation was
about 30% faster
in Firebird compared to the best python method, and once combined with
simulated real world queries to build JSON data on tables
the SQL code performed nearly 10 times faster in some cases.
Admittedly Firebird is not known for its speed, but I think the same
principles will apply in most RDBMs.
Even some other new SQL technologies (like
https://msdn.microsoft.com/en-us/library/dn133184.aspx , NuoDB) could
combine
to make very interesting high performance systems.

In spite of the project name, I don't really want to limit the project
to SQL only, I have some ideas in progress
(https://github.com/quale-quest/sql-mvc/blob/master/lib/query-proc/query-proc.js)
to make the
principles apply to any query language (targeting Mongo first)

3) Aims - I would like to turn this into a viable platform, with a team
of developers working full time on it,
for that reason I am really unsure about a sustainable license model, I
am leaning towards a dual licensing with GNU AGPLv3 as the free version.

4) https://www.npmjs.com/package/sql-mvc,
https://github.com/quale-quest/sql-mvc
http://todomvc.sql-mvc.com/
are the "official sites"


5) Real-world, not any yet. It's predecessor's sites are used in a
number of corporate Intranet application which I cannot disclose.

Regards
Lafras
> --
> You received this message because you are subscribed to the Google
> Groups "sql-mvc-talk" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to sql-mvc-talk...@googlegroups.com
> <mailto:sql-mvc-talk...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sql-mvc-talk/73179537-cba9-4ca4-9865-9bb73eb91a8d%40googlegroups.com
> <https://groups.google.com/d/msgid/sql-mvc-talk/73179537-cba9-4ca4-9865-9bb73eb91a8d%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

Zubair Quraishi

unread,
Jan 22, 2015, 4:49:02 AM1/22/15
to sql-mv...@googlegroups.com
Hi Lafras,

 Ok, cool, your seem to be really committed to this based on your answers. So is the aim to make something like Meteor.js? 

Zubair

Lafras Henning

unread,
Jan 22, 2015, 5:40:26 AM1/22/15
to sql-mv...@googlegroups.com
Hi Zubair,

Like Meteor.js, in terms of a company, I don't know much other than what
is on their about page, but an approximation of this would be cool,
except it would be distributed world wide, not a central office.

Unlike the Meteor project who's vision is that JavaScript is the
universal programming language to rule the world,

I think my vision is :

Javascript is a general purpose systems level programming language, it
should NOT be used to write applications, it should be used to write
infrastructure for applications.

SQL is a 4th generation data level language, it should be used to write
applications in, but it can't as it has no infrastructure (in the
language) to deliver those applications.

SQL-MVC is intended to provide a means for infrastructure written in
JavaScript to be abstracted and combined with Query Language Application
Extensions (QUALE)
to deliver an application.

Goals for the platform:
1) Should NOT try to understand SQL (or other query language), only
provide a mechanism for it to be joined into an application.
2) Should NOT try to understand JS,HTML or provide infrastructure or
widgets (etc) , only the mechanism for a framework to be joined into an
application.

Goals for the framework:
1)To have many frameworks containing widgets, themes, servers written in
any language.

Idealistically:
Frameworks will evolve, always get smarter and fancier using newer
technologies, the platform will at some point become stable,
the mechanism will be complete, you will be able to join any framework
with your app , running whatever back end server
(node,java,python,c,...) without changing the app code.

This will be a Qualic system.
(https://github.com/quale-quest/sql-mvc/wiki/Paradigm-inversion---Mind-set-shift#my-definitions)
> <https://github.com/quale-quest/sql-mvc/blob/master/lib/query-proc/query-proc.js>)
>
> to make the
> principles apply to any query language (targeting Mongo first)
>
> 3) Aims - I would like to turn this into a viable platform, with a team
> of developers working full time on it,
> for that reason I am really unsure about a sustainable license model, I
> am leaning towards a dual licensing with GNU AGPLv3 as the free
> version.
>
> 4) https://www.npmjs.com/package/sql-mvc
> <https://www.npmjs.com/package/sql-mvc>,
> https://github.com/quale-quest/sql-mvc
> > an email to sql-mvc-talk...@googlegroups.com <javascript:>
> > <mailto:sql-mvc-talk...@googlegroups.com <javascript:>>.
> <https://groups.google.com/d/msgid/sql-mvc-talk/73179537-cba9-4ca4-9865-9bb73eb91a8d%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/optout>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "sql-mvc-talk" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to sql-mvc-talk...@googlegroups.com
> <mailto:sql-mvc-talk...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sql-mvc-talk/c7e7e72f-7d8b-49d1-9d03-3f6186c7ab0c%40googlegroups.com
> <https://groups.google.com/d/msgid/sql-mvc-talk/c7e7e72f-7d8b-49d1-9d03-3f6186c7ab0c%40googlegroups.com?utm_medium=email&utm_source=footer>.

Zubair Quraishi

unread,
Jan 22, 2015, 6:42:26 AM1/22/15
to sql-mv...@googlegroups.com
Send me your phone number and I can call you?
>      > <mailto:sql-mvc-talk+unsub...@googlegroups.com <javascript:>>.

Zubair Quraishi

unread,
Jan 22, 2015, 6:59:47 AM1/22/15
to sql-mv...@googlegroups.com
I tried calling back about several times but get engaged signal


On Thursday, January 22, 2015 at 11:40:26 AM UTC+1, lafras wrote:
>      > <mailto:sql-mvc-talk+unsub...@googlegroups.com <javascript:>>.

Lafras Henning

unread,
Jan 22, 2015, 9:54:48 AM1/22/15
to sql-mv...@googlegroups.com
Hi Zubair,

Thanks for the chat, I have looked at the info you suggested...

It seems is what Eve and kparc is all about fundamental programming
paradigms, Haskell I found very difficult to understand initially, and
still..., the one comment I read about k is that "As a beginner it's
beyond cryptic".

There has been a plethora of languages, one of my favourite sites is
http://www.99-bottles-of-beer.net/ , but whatever language you choose ,
whether the syntax is compact , verbose or English, you still express
the application either in minute detail, or abstractly using the ui
generator of the platform it runs on. These are still essentially
general purpose programming languages.

http://incidentalcomplexity.com/ is very interesting an really
highlights the issues. Moving incidental complexity out of the
application and into the infrastructure is what SQL-MVC is about.


SQL-MVC is not about creating a new language, it is about extending
existing query languages, to become the front end development language,
providing a mechanism to couple queries to frameworks, as efficiently
as possible with as minimal glue logic, an yet remain query and
framework agnostic.





Regards
Lafras
> <https://github.com/quale-quest/sql-mvc/wiki/Paradigm-inversion---Mind-set-shift#my-definitions>)
> > > <mailto:sql-mvc-talk...@googlegroups.com
> <javascript:> <javascript:>>.
> > an email to sql-mvc-talk...@googlegroups.com <javascript:>
> > <mailto:sql-mvc-talk...@googlegroups.com <javascript:>>.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/sql-mvc-talk/c7e7e72f-7d8b-49d1-9d03-3f6186c7ab0c%40googlegroups.com
> <https://groups.google.com/d/msgid/sql-mvc-talk/c7e7e72f-7d8b-49d1-9d03-3f6186c7ab0c%40googlegroups.com>
>
> >
> <https://groups.google.com/d/msgid/sql-mvc-talk/c7e7e72f-7d8b-49d1-9d03-3f6186c7ab0c%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/sql-mvc-talk/c7e7e72f-7d8b-49d1-9d03-3f6186c7ab0c%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
> > For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "sql-mvc-talk" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to sql-mvc-talk...@googlegroups.com
> <mailto:sql-mvc-talk...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sql-mvc-talk/49f52509-754e-4ceb-a2ca-064e7d6ef29c%40googlegroups.com
> <https://groups.google.com/d/msgid/sql-mvc-talk/49f52509-754e-4ceb-a2ca-064e7d6ef29c%40googlegroups.com?utm_medium=email&utm_source=footer>.

Zubair Quraishi

unread,
Jan 22, 2015, 11:33:02 PM1/22/15
to sql-mv...@googlegroups.com
Hi Lafras,

Yes, it was great to chat, thanks. Yes, 99 bottles of beer was one that I used to visit alot, nice to hear someone else mention it :) Ok, so that makes sense about extending SQL. So am I right in thinking that the the sql mvc could cross compile into any language. So to take the github code:

<#:model
--:{regex:"regex:/varchar/i",autosave:yes}
CREATE TABLE TODO_MVC               --:{as:"Table"} 
(
  REF VARCHAR(40),                  --:{as:"pk"}
  NAME VARCHAR(100),    --:{as:"Text",size:40,title:"todo",onupdate:"owner=session.id"}  
  OWNER VARCHAR(40),                --:{Type:"Hide"}
  STATUS VARCHAR(10) default ''     --:{Type:"Pick",List:"Ticked"}  
);
/>
Would compile into Javascript in this first case, but could compile into any other language as well?
Zubair
>      >      > <mailto:sql-mvc-talk+unsub...@googlegroups.com
>     <javascript:> <javascript:>>.
>      >      > To view this discussion on the web visit
>      >      >
>      >
>     https://groups.google.com/d/msgid/sql-mvc-talk/73179537-cba9-4ca4-9865-9bb73eb91a8d%40googlegroups.com
>     <https://groups.google.com/d/msgid/sql-mvc-talk/73179537-cba9-4ca4-9865-9bb73eb91a8d%40googlegroups.com>
>
>      >
>     <https://groups.google.com/d/msgid/sql-mvc-talk/73179537-cba9-4ca4-9865-9bb73eb91a8d%40googlegroups.com
>     <https://groups.google.com/d/msgid/sql-mvc-talk/73179537-cba9-4ca4-9865-9bb73eb91a8d%40googlegroups.com>>
>
>      >
>      >      >
>      >
>     <https://groups.google.com/d/msgid/sql-mvc-talk/73179537-cba9-4ca4-9865-9bb73eb91a8d%40googlegroups.com?utm_medium=email&utm_source=footer
>     <https://groups.google.com/d/msgid/sql-mvc-talk/73179537-cba9-4ca4-9865-9bb73eb91a8d%40googlegroups.com?utm_medium=email&utm_source=footer>
>
>      >
>     <https://groups.google.com/d/msgid/sql-mvc-talk/73179537-cba9-4ca4-9865-9bb73eb91a8d%40googlegroups.com?utm_medium=email&utm_source=footer
>     <https://groups.google.com/d/msgid/sql-mvc-talk/73179537-cba9-4ca4-9865-9bb73eb91a8d%40googlegroups.com?utm_medium=email&utm_source=footer>>>.
>
>      >
>      >      > For more options, visit https://groups.google.com/d/optout
>     <https://groups.google.com/d/optout>
>      >     <https://groups.google.com/d/optout
>     <https://groups.google.com/d/optout>>.
>      >
>      > --
>      > You received this message because you are subscribed to the Google
>      > Groups "sql-mvc-talk" group.
>      > To unsubscribe from this group and stop receiving emails from it,
>     send
>      > an email to sql-mvc-talk...@googlegroups.com <javascript:>
>      > <mailto:sql-mvc-talk+unsub...@googlegroups.com <javascript:>>.

Lafras Henning

unread,
Jan 23, 2015, 12:52:50 AM1/23/15
to sql-mv...@googlegroups.com
Hi Zubair,

Yes, the core of the platform is a compiler (Quicc),
ideally it should be language agnostic, although it is hard to make a
system strictly to this spec, so initially it is more about what works,
but this is the goal.

The example shows The Quicc format (Quale Inline Comment Code),
The <# /> is to escape out of the HTML parser which is the default for
the page. The -- is a SQL comment. So if you read the remainder it is
just a plain SQL create statement.

Quicc does not need to understand this at all, it can be any query
language, or dialect. This will be passed to the SQL server unaltered.

This example is a create statement but buttons, tables and forms work in
the same way using select statements.

Once the page is built, the SQL runs on whichever SQL server it was
written for and produces the JSON data.


The application server (in this case node.js and socket-stream), is a
very thin layer that passes the JSON between the browser and the SQL
server, it can be written in any language and does not need to
understand any of the application, during proof of concept phase I used
python and cherrypy to do this and the server was only about 30 lines.
Here SQL-MVC is also language agnostic. I fact I am have some issues
with the node-firebird driver (which still is immature also) so I may
very well end up with a python server in the meantime.



Quicc remains framework agnostic (JavaScript/html etc) as follows:
(read this in conjunction with the file
Quale/Lib/Models/fb_base_model.quicc)

The comments are interpreted by the compiler as :
--:{JSON} builds ad-hock Qualia (Attributes or properties)
but here even quicc does not attempt interpret them, it only builds
them, a very simple method is used to build cascading qualia.

--:{regex... creates a regex search that will match the left part of
each line that has a --: and add the qualia defined in the regex to the
context.

In the framework library there is a line:
--:{regex:"regex:/varchar/i",Default_length:"20",length:"regex:/(\\d+)/",name:"regex:/(\\w+)/",Type:"Text",Action:"View"}

This regex finds each varchar, and extracts a name for the field,
together with some very basic defaults (there will be such a line for
each datatype).

All regex'es defined are applied to all fields, so we can progressively
add higher level qualia as we go up the model, like in the example we
use a regex to switch on autosave.


--:{class:"pk",Type:"Hide",Action:"Hide",PrimaryKey:true}
A special key "class" defines this qualia by name and can be referred to
by using "as":
REF VARCHAR(40), --:{as:"pk"}



When a table or form is created, quicc uses the "Type" "Action" and
Style elements to look up html/JavaScript fragments in the framework.
(look at server/compiler/Elements_UI_7.json)

It does not attempt to understand the JavaScript, but uses the Moustache
template system to substitute additional values from the qualia into the
fragments.

So even here if the web browser's native or preferred language was to
change from JavaScript, it would not affect the platform (but only the
framework).

The idea is I should be able to replace all the innards and still be
able to compile the same app for a non web/html/JavaScript world, that
performs substantially the same (which is the definition of a qualic system)


Regards
Lafras
















On 2015/01/23 06:33 AM, Zubair Quraishi wrote:
> Hi Lafras,
>
> http://incidentalcomplexity.com/ <http://incidentalcomplexity.com/>
> > > > <mailto:sql-mvc-talk...@googlegroups.com
> <javascript:>
> > > <mailto:sql-mvc-talk...@googlegroups.com
> <javascript:> <javascript:>>.
> > > To view this discussion on the web visit
> > >
> >
> https://groups.google.com/d/msgid/sql-mvc-talk/c7e7e72f-7d8b-49d1-9d03-3f6186c7ab0c%40googlegroups.com
> > <https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>>.
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "sql-mvc-talk" group.
> > To unsubscribe from this group and stop receiving emails from it,
> send
> > an email to sql-mvc-talk...@googlegroups.com <javascript:>
> > <mailto:sql-mvc-talk...@googlegroups.com <javascript:>>.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/sql-mvc-talk/49f52509-754e-4ceb-a2ca-064e7d6ef29c%40googlegroups.com
> <https://groups.google.com/d/msgid/sql-mvc-talk/49f52509-754e-4ceb-a2ca-064e7d6ef29c%40googlegroups.com>
>
> >
> <https://groups.google.com/d/msgid/sql-mvc-talk/49f52509-754e-4ceb-a2ca-064e7d6ef29c%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/sql-mvc-talk/49f52509-754e-4ceb-a2ca-064e7d6ef29c%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
> > For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "sql-mvc-talk" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to sql-mvc-talk...@googlegroups.com
> <mailto:sql-mvc-talk...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sql-mvc-talk/0bf1ee53-1194-4c87-b9b9-9dbe187a5b85%40googlegroups.com
> <https://groups.google.com/d/msgid/sql-mvc-talk/0bf1ee53-1194-4c87-b9b9-9dbe187a5b85%40googlegroups.com?utm_medium=email&utm_source=footer>.

Zubair Quraishi

unread,
Jan 23, 2015, 3:31:11 AM1/23/15
to sql-mv...@googlegroups.com
Hi, 

 So just to break down what you have said. The -- are comments. So would the following have worked exactly the same in the code?

<#:model CREATE TABLE TODO_MVC (REF VARCHAR(40),  NAME VARCHAR(100), OWNER VARCHAR(40),  STATUS VARCHAR(10) default ''); />
I was just wondering why you didn't use this shorter version which looks alot easier to understand?

Zubair

>      >      >      > <mailto:sql-mvc-talk+unsub...@googlegroups.com
>      >      > <mailto:sql-mvc-talk+unsub...@googlegroups.com
>     <javascript:> <javascript:>>.
>      >      > To view this discussion on the web visit
>      >      >
>      >
>     https://groups.google.com/d/msgid/sql-mvc-talk/c7e7e72f-7d8b-49d1-9d03-3f6186c7ab0c%40googlegroups.com
>     <https://groups.google.com/d/msgid/sql-mvc-talk/c7e7e72f-7d8b-49d1-9d03-3f6186c7ab0c%40googlegroups.com>
>
>      >
>     <https://groups.google.com/d/msgid/sql-mvc-talk/c7e7e72f-7d8b-49d1-9d03-3f6186c7ab0c%40googlegroups.com
>     <https://groups.google.com/d/msgid/sql-mvc-talk/c7e7e72f-7d8b-49d1-9d03-3f6186c7ab0c%40googlegroups.com>>
>
>      >
>      >      >
>      >
>     <https://groups.google.com/d/msgid/sql-mvc-talk/c7e7e72f-7d8b-49d1-9d03-3f6186c7ab0c%40googlegroups.com?utm_medium=email&utm_source=footer
>     <https://groups.google.com/d/msgid/sql-mvc-talk/c7e7e72f-7d8b-49d1-9d03-3f6186c7ab0c%40googlegroups.com?utm_medium=email&utm_source=footer>
>
>      >
>     <https://groups.google.com/d/msgid/sql-mvc-talk/c7e7e72f-7d8b-49d1-9d03-3f6186c7ab0c%40googlegroups.com?utm_medium=email&utm_source=footer
>     <https://groups.google.com/d/msgid/sql-mvc-talk/c7e7e72f-7d8b-49d1-9d03-3f6186c7ab0c%40googlegroups.com?utm_medium=email&utm_source=footer>>>.
>
>      >
>      >      > For more options, visit https://groups.google.com/d/optout
>     <https://groups.google.com/d/optout>
>      >     <https://groups.google.com/d/optout
>     <https://groups.google.com/d/optout>>.
>      >
>      > --
>      > You received this message because you are subscribed to the Google
>      > Groups "sql-mvc-talk" group.
>      > To unsubscribe from this group and stop receiving emails from it,
>     send
>      > an email to sql-mvc-talk...@googlegroups.com <javascript:>
>      > <mailto:sql-mvc-talk+unsub...@googlegroups.com <javascript:>>.

Lafras Henning

unread,
Jan 23, 2015, 8:28:27 AM1/23/15
to
Hi Zubair, No,

The Qualia is in Javascript Object Literal Notation  (JSOL) a relaxed
version of JSON, but we still call it JSON for convenience, as JSOL also
has another meaning which can be confusing if you google for it.
The Qualia is placed in the comments, they direct the front end of the
application.


A detailed step by step example:
I presume you know JavaScript and mustache Logic-less templates.
(I have adjusted/removed a few implementation details for brevity’s sake)

Staring with:
<#:model
--:{regex:"regex:/varchar/i",autosave:yes}
CREATE TABLE TODO_MVC                --:{as:"Table"}
(
   REF VARCHAR(40),                    --:{as:"pk"}
   NAME VARCHAR(100),
--:{as:"Text",size:40,title:"todo",onupdate:"owner=session.id"}
   OWNER VARCHAR(40),                --:{Type:"Hide"}
   STATUS VARCHAR(10) default ''        --:{Type:"Pick",List:"Ticked"}
);
/>
<#:table
Select  --:{from:"TODO_MVC",autoinsert:"top",tablestyle:"Todo"}
STATUS, --:{Action:"Edit"}
NAME,   --:{Action:"Edit","placeholder":"What needs to be done"}
REF        --:{Action:"View",Type:"Hide"}
 From TODO_MVC
where (owner=session.id and ( (my.todo_type='' and status!='3' )
or( status='' and my.todo_type='1')or(status='1' and my.todo_type='2')))
/>





Ignore the html escape, now we have:
--:{regex:"regex:/varchar/i",autosave:yes}
CREATE TABLE TODO_MVC                --:{as:"Table"}
(
   REF VARCHAR(40),                    --:{as:"pk"}
   NAME VARCHAR(100),
--:{as:"Text",size:40,title:"todo",onupdate:"owner=session.id"}
   OWNER VARCHAR(40),                --:{Type:"Hide"}
   STATUS VARCHAR(10) default ''        --:{Type:"Pick",List:"Ticked"}
);
Select  --:{from:"TODO_MVC",autoinsert:"top",tablestyle:"Todo"}
STATUS, --:{Action:"Edit"}
NAME,   --:{Action:"Edit","placeholder":"What needs to be done"}
REF        --:{Action:"View",Type:"Hide"}
 From TODO_MVC
where (owner=session.id and ( (my.todo_type='' and status!='3' )
or( status='' and my.todo_type='1')or(status='1' and my.todo_type='2')))



Ignore the SQL comments, now we have:
CREATE TABLE TODO_MVC
(
   REF VARCHAR(40),
   NAME VARCHAR(100),
   OWNER VARCHAR(40),
   STATUS VARCHAR(10) default ''
);
Select
STATUS,
NAME,
REF
 From TODO_MVC
where (owner=session.id and ( (my.todo_type='' and status!='3' )
or( status='' and my.todo_type='1')or(status='1' and my.todo_type='2')))


This is a plain create statement and a select statement, the select
statement formed into the stored procedure to concatenate the rows into
a JSON object something like this:

tfid=90000000;first=' '; res=res||',"t8":[';
for select STATUS, NAME,  REF        
 From TODO_MVC
where .... into :f0,:f1,:f2 do
  begin
row=first||'["'||:tfid||'",'||:f0||','||:f1||','||:f2||']';
first=',';res=res||row;
end
res=res||']';



When run it will produce JSON like this
     "t8": [[
             "80000000",
             "",
             "test1",
             "0.2995"
         ],        [
             "80000002",
             "",
             "test2",
             "0.2997"
         ],        [
             "80000004",
             "",
             "test3",
             "0.2999"
         ] ]



This data can be delivered to the web browser, but what will it make
from it?


So again take the original:
<#:model
--:{regex:"regex:/varchar/i",autosave:yes}
CREATE TABLE TODO_MVC                --:{as:"Table"}
(
   REF VARCHAR(40),                    --:{as:"pk"}
   NAME VARCHAR(100),
--:{as:"Text",size:40,title:"todo",onupdate:"owner=session.id"}
   OWNER VARCHAR(40),                --:{Type:"Hide"}
   STATUS VARCHAR(10) default ''        --:{Type:"Pick",List:"Ticked"}
);
/>
<#:table
Select  --:{from:"TODO_MVC",autoinsert:"top",tablestyle:"Todo"}
STATUS, --:{Action:"Edit"}
NAME,   --:{Action:"Edit","placeholder":"What needs to be done"}
REF        --:{Action:"View",Type:"Hide"}
 From TODO_MVC
where (owner=session.id and ( (my.todo_type='' and status!='3' )
or( status='' and my.todo_type='1')or(status='1' and my.todo_type='2')))
/>



Ignore the html escape and the SQL (everything upto the end of --:) but
remember the names - they get copied over by the the regex)

{name:"TODO_MVC",as:"Table"}
{name:"REF",as:"pk"}
{name:"NAME",as:"Text",size:40,title:"todo",onupdate:"owner=session.id"}
{name:"OWNER",Type:"Hide"}
{name:"STATUS ",Type:"Pick",List:"Ticked"}

{name:"",from:"TODO_MVC",autoinsert:"top",tablestyle:"Todo"}
{name:"STATUS",Action:"Edit"}
{name:"NAME",Action:"Edit","placeholder":"What needs to be done"}
{name:"REF        ",Action:"View",Type:"Hide"}


Now merge the datasets on name,
also merge with what would have been the datasets from the regex
searches so now we have the fields into a JSON-like object(more or less):

[{name:"STATUS",Action:"Edit",Type:"Pick",List:"Ticked"},
{name:"NAME",Type:"Text",Action:"Edit","placeholder":"What needs to be
done", as:"Text",size:40,title:"todo",onupdate:"owner=session.id"},
{name:"REF",Type:"Text",Action:"View",Type:"Hide",as:"pk"},
]



so now:
Take each field, get the html fragment from the framework
(server/compiler/Elements_UI_7.json) that corresponds to
{Type,Action,Style}.

for example the field named  "NAME" Type:"Text",Action:"Edit" fragment is:

<div class= "fieldwrap">
<input id='{{id}}' type="text"
{{#field.f.name}}title="{{field.f.name}}"{{/field.f.name}}
{{#field.f.placeholder}}placeholder="{{field.f.placeholder}}"{{/field.f.placeholder}}

{{#field.f.autosave}}data-autosave=\"{{field.f.autosave}}"{{/field.f.autosave}}
{{#field.f.size}}size="{{field.f.size}}"{{/field.f.size}}{{#field.f.maxlength}}maxlength="{{field.f.maxlength}}"{{/field.f.maxlength}}

onchange="zxd(event,[[0]],{{QryOffset}});" value="[[{{pop}}]]" /></div>        



Once this this Fragment passes through mustache with the Qualia of the
field it will produce:

<div class= "fieldwrap">
<input id=''
type="text"
title="todo"
placeholder="What needs to be done "
data-autosave="yes"
size="40"
onchange="zxd(event,{{0}},1);"
value="{{2}}" />
</div>


A full table of the example would look like this:
<div > <form autocomplete="off"><table class="qq-table" id="t8">
<thead><tr></tr></thead><tbody>{{#t8}}<tr><th scope="row"><div
data-qqpickvalue='{{1}}'>{{{pick(1,'Ticked',0,'0','"data-autosave":"yes"
')}}}</div></th><td>
<div class= "fieldwrap"><input id='' type="text"
title="todo"placeholder="What needs to be done (tab to save)"
data-autosave="yes" size="40"  onchange="zxd(event,{{0}},1);"
value="{{2}}" /></div>
</td></tr>{{/t8}}</tbody>
</table></form></div>

This now gets saved and sent to the browser as pre-compiled Hogan templates.

You will notice the {{#t8}} in the template corresponds to the JSON
object generated by the SQL code, and the {{0}} corresponds to the first
field per row thereof. So when the Hogan and JSON are combined we get:


<div> <form autocomplete="off"><table class="qq-table" id="t8">
<thead><tr></tr></thead>
<tbody><tr><th scope="row"><div data-qqpickvalue=""><label><div
class="checker"><span><input name="80000000-0"
onchange="zxd(event,80000000,0);" value="1" data-autosave="yes"
type="checkbox"></span></div></label></div></th><td><div
class="fieldwrap"><input class="uniform-input text" id="" title="todo"
placeholder="What needs to be done (tab to save)" data-autosave="yes"
size="40" onchange="zxd(event,80000000,1);" value="test1"
type="text"></div></td></tr><tr><th scope="row"><div
data-qqpickvalue=""><label><div class="checker"><span><input
name="80000002-0" onchange="zxd(event,80000002,0);" value="1"
data-autosave="yes"
type="checkbox"></span></div></label></div></th><td><div
class="fieldwrap"><input class="uniform-input text" id="" title="todo"
placeholder="What needs to be done (tab to save)" data-autosave="yes"
size="40" onchange="zxd(event,80000002,1);" value="test2"
type="text"></div></td></tr><tr><th scope="row"><div
data-qqpickvalue=""><label><div class="checker"><span><input
name="80000004-0" onchange="zxd(event,80000004,0);" value="1"
data-autosave="yes"
type="checkbox"></span></div></label></div></th><td><div
class="fieldwrap"><input class="uniform-input text" id="" title="todo"
placeholder="What needs to be done (tab to save)" data-autosave="yes"
size="40" onchange="zxd(event,80000004,1);" value="test3"
type="text"></div></td></tr></tbody>
</table></form></div>


Which is a proper html form/table.

The onchange="zxd(event,80000004,1), is in the framework and handles the
client side of posting back changes.


Regards
Lafras
>     <http://session.id>"}
>     <https://groups.google.com/d/msgid/sql-mvc-talk/49f52509-754e-4ceb-a2ca-064e7d6ef29c%40googlegroups.com>
>
>      >
>     <https://groups.google.com/d/msgid/sql-mvc-talk/49f52509-754e-4ceb-a2ca-064e7d6ef29c%40googlegroups.com
>     <https://groups.google.com/d/msgid/sql-mvc-talk/49f52509-754e-4ceb-a2ca-064e7d6ef29c%40googlegroups.com>>
>
>      >
>      >      >
>      >
>     <https://groups.google.com/d/msgid/sql-mvc-talk/49f52509-754e-4ceb-a2ca-064e7d6ef29c%40googlegroups.com?utm_medium=email&utm_source=footer
>     <https://groups.google.com/d/msgid/sql-mvc-talk/49f52509-754e-4ceb-a2ca-064e7d6ef29c%40googlegroups.com?utm_medium=email&utm_source=footer>
>
>      >
>     <https://groups.google.com/d/msgid/sql-mvc-talk/49f52509-754e-4ceb-a2ca-064e7d6ef29c%40googlegroups.com?utm_medium=email&utm_source=footer
>     <https://groups.google.com/d/msgid/sql-mvc-talk/49f52509-754e-4ceb-a2ca-064e7d6ef29c%40googlegroups.com?utm_medium=email&utm_source=footer>>>.
>
>      >
>      >      > For more options, visit https://groups.google.com/d/optout
>     <https://groups.google.com/d/optout>
>      >     <https://groups.google.com/d/optout
>     <https://groups.google.com/d/optout>>.
>      >
>      > --
>      > You received this message because you are subscribed to the Google
>      > Groups "sql-mvc-talk" group.
>      > To unsubscribe from this group and stop receiving emails from it,
>     send
>      > an email to sql-mvc-talk...@googlegroups.com <javascript:>
>      > <mailto:sql-mvc-talk+unsub...@googlegroups.com <javascript:>>.
>      > To view this discussion on the web visit
>      >
>     <https://groups.google.com/d/optout>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "sql-mvc-talk" group.
> To unsubscribe from this group and stop receiving emails from it, send
> <mailto:sql-mvc-talk+unsub...@googlegroups.com>.
> To view this discussion on the web visit

Zubair Quraishi

unread,
Jan 23, 2015, 8:54:52 AM1/23/15
to sql-mv...@googlegroups.com
Hi Lafras,
 
 I tried to follow it but I will admit I got a bit lost. I think the you told me it is hard to explain what it is, and maybe that is because you are too close to it as the developer. Maybe if I write about it then I can explain it in a way that everyone can understand it, so I think I need to write this out as a blog post to make sure I understand it right. Would that be ok with you? You could give me feedback on whether I understand the concept or not.

Thanks
Zubair

On Friday, January 23, 2015 at 2:28:27 PM UTC+1, lafras wrote:
Hi Zubair, No,

The Qualia is in Javascript Object Literal Notation  (JSOL) a relaxed
version of JSON, but we still call it JSON for convenience, as JSOL also
has another meaning which can be confusing if you google for it.
The Qualia is placed in the comments, they direct the front end of the
application.


A detailed step by step example:
I presume you know JavaScript and mustache Logic-less templates.
(I have adjusted/removed a few implementation details for brevity’s sake)

Staring with:
<#:model
--:{regex:"regex:/varchar/i",autosave:yes}
CREATE TABLE TODO_MVC                --:{as:"Table"}
(
   REF VARCHAR(40),                    --:{as:"pk"}
   NAME VARCHAR(100),
--:{as:"Text",size:40,title:"todo",onupdate:"owner=session.id"}
   OWNER VARCHAR(40),                --:{Type:"Hide"}
   STATUS VARCHAR(10) default ''        --:{Type:"Pick",List:"Ticked"}
);
/>
<#:table
Select  --:{from:"TODO_MVC",autoinsert:"top",tablestyle:"Todo"}
STATUS, --:{Action:"Edit"}
NAME,   --:{Action:"Edit","placeholder":"What needs to be done"}
REF        --:{Action:"View",Type:"Hide"}
 From TODO_MVC
where (owner=session.id and ( (my.todo_type='' and status!='3' )
or( status='' and my.todo_type='1')or(status='1' and my.todo_type='2')))
/>





Ignore the html escape, now we have:
--:{regex:"regex:/varchar/i",autosave:yes}
CREATE TABLE TODO_MVC                --:{as:"Table"}
(
   REF VARCHAR(40),                    --:{as:"pk"}
   NAME VARCHAR(100),
--:{as:"Text",size:40,title:"todo",onupdate:"owner=session.id"}
   OWNER VARCHAR(40),                --:{Type:"Hide"}
   STATUS VARCHAR(10) default ''        --:{Type:"Pick",List:"Ticked"}
);
Select  --:{from:"TODO_MVC",autoinsert:"top",tablestyle:"Todo"}
STATUS, --:{Action:"Edit"}
NAME,   --:{Action:"Edit","placeholder":"What needs to be done"}
REF        --:{Action:"View",Type:"Hide"}
 From TODO_MVC
where (owner=session.id and ( (my.todo_type='' and status!='3' )
or( status='' and my.todo_type='1')or(status='1' and my.todo_type='2')))



Ignore the SQL comments, now we have:
CREATE TABLE TODO_MVC
(
   REF VARCHAR(40),
   NAME VARCHAR(100),
   OWNER VARCHAR(40),
   STATUS VARCHAR(10) default ''
);
Select
STATUS,
NAME,
REF
 From TODO_MVC
where (owner=session.id and ( (my.todo_type='' and status!='3' )
or( status='' and my.todo_type='1')or(status='1' and my.todo_type='2')))


This is a plain create statement and a select statement, the select
statement formed into the stored procedure to concatenate the rows into
a JSON object something like this:

tfid=90000000;first=' '; res=res||',"t9":[';
<#:model
--:{regex:"regex:/varchar/i",autosave:yes}
CREATE TABLE TODO_MVC                --:{as:"Table"}
(
   REF VARCHAR(40),                    --:{as:"pk"}
   NAME VARCHAR(100),
--:{as:"Text",size:40,title:"todo",onupdate:"owner=session.id"}
   OWNER VARCHAR(40),                --:{Type:"Hide"}
   STATUS VARCHAR(10) default ''        --:{Type:"Pick",List:"Ticked"}
);
/>
>     <http://session.id>"}

lafras

unread,
Feb 15, 2015, 6:48:30 AM2/15/15
to sql-mv...@googlegroups.com
This discussion has moved to SQL-First group on linkedin
Reply all
Reply to author
Forward
0 new messages