Because you shouldn't have to hand code SQL like a barbarian
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.idea
project
projectFilesBackup/.idea
src
.gitignore
LICENSE
README.md
build.sbt
modl-mode.el
squall.conf

README.md

Squall

An abstraction layer over persistence , squall takes as input a tiny language describing relationships and attempts to create tables and SQL and index on them to make saving your data both effortless and speedy. It currently outputs PHP or JAVA and supports Mysql, HSQL and Postgres.

I just use this model-mode for editing model files.


simple.modl

model User
{
	name : String
	email : String(50) # That's length 50 in the database
	posts : Post[1-N] # And this is a relationship, 1 user to Many(N) Post('s)
}

model Post
{
	description : String
	content : Text
}

The above generates code in java ( directly below ) and php ( below below ) to make it easy to create and manipulate objects of your data model. All the SQL is executed and generated after running the squall program you shouldn't need to manually create anything.

Test.java

class Main 
{
	public static void main (String [] args )
	{
		Post post1 = Post.create().
			setDescription("Something").
			setContent("Lots of content");

		Post post2 = Post.create().
			setDescription("Somethingelse").
			setContent("Tons of content");

		User user = User.create().
			setName("Charlie").
			setEmail("charlie@squiggles.com").
			addPosts(post1).
			addPosts(post2);

		user.upsert();

		User.find("name = 'Charlie'").forEach(foundUser ->
		{
		    assert(foundUser.getPosts().size() == 2);
		    System.out.println(foundUser.toPrettyString());
		});
	}

}

Test.php

<?php

    require_once "tests/api.php";

    $post1 = new Post();
    $post1->setDescription("Something")->
        setContent("A lot of the goods");

    $post2 = new Post();
    $post2->setDescription("Another")->
        setContent("Sweet sweet post");
    
    $user = new User();
    $user->setName("Charlie")->
        setEmail("charlie@squiggly.com")->
        addPost($post1)->
        addPost($post2)->
        upsert();

    foreach ( User::find("name = 'Charlie'") as $user )
    {
        assert(count($user->getPosts()) == 2 );
        print_r($user);
    }

?>

squall.conf

database_name=SQUALL_TESTS
database_user=squall_user
database_password=x
database_vendor=mysql
database_host=localhost

output_language=php
model_file=src/main/resources/testconfig/scratch/scratch.modl
output_directory=src/test/php/
skip_confirmation=true
  • Creates tables dumbly and automatically that doesnt keep track of its revisions
  • Uses connection pooling
  • +function will create a function and also index on the marked fields
model User {
	name : String
	email : String +function login
	password : String +function login
}

User.login(someEmail,somePassword);

Some disadvantages

  • Just blows away the schema, you have to hand update schemas in production
  • Uses native SQL.