Giter VIP home page Giter VIP logo

fsqlf's People

Contributors

aguynamedryan avatar bendavis78 avatar dnsmkl avatar felixhummel avatar olshevskiy87 avatar xevix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fsqlf's Issues

[feature wish] `cli` make target

Your makefile contains only all target. Please add cli target as an option for people who don't need GUI and its dependencies:

cli: $(EXEC_CLI)

I don't PR because having issues compiling it (therefore can't test, I know it's trivial change but still).

Doesn't handle + & etc. in text strings

All of these fail translation:

update audio set ztagschanged = 1, composer = replace( composer, "+ the Mechanics", "Mike + the Mechanics") where albumartist = "Mike + the Mechanics" AND composer NOT LIKE "%Mike + the Mechanics%";

update audio set ztagschanged = 1, composer = replace( composer, "+ the Machine", "Florence + the Machine") where albumartist = "Florence + the Machine" AND composer NOT LIKE "%Florence + the Machine%";

update audio set ztagschanged = 1, composer = replace( composer, "+ David", "David + David") where albumartist = "David + David" AND composer NOT LIKE "%David + David%";
update audio set ztagschanged = 1, composer = replace( composer, "& Wine", "Calexico\\Iron & Wine") where albumartist = "Calexico\\Iron & Wine" AND composer NOT LIKE "%Calexico\\Iron & Wine%";

update audio set ztagschanged = 1, composer = replace( composer, "& Wine", "Iron & Wine") where albumartist = "Iron & Wine" AND composer NOT LIKE "%Iron & Wine%";


fsqlf: utils/stack/stack.c:42: stack_peek: Assertion `stk->length > 0 && stk->length < (100)' failed.
, composer=replace ( composer,"0 )Aborted (core dumped)

bug

SELECT  *  FROM `online`.`ol_ad_channel_new` `t` 

will gen:

SELECT
  *
FROM `online`.`ol_ad_channel_new``t`

error :

MYSQL:ERR:1146:Table 'online.ol_ad_channel_new`t' doesn't exist:SELECT * FROM `online`.`ol_ad_channel_new``t` 

Feature request: new keywords

  1. I'd like to see DELETE and USING added to the keyword list.
  2. Statements starting with DELETE seem to turn formatting off.

unchanged (before/after):

delete a.* from db1.t1 a left join db2.t2 b using (f1,f2) where b.f1 is null;

though the > symbol seems to counteract it here:
before:

delete a.* from db1.t1 a where a.f1 > ( select b.f1 from db2.t2 b );

after:

 delete a.* from db1.t1 a where a.f1 >
(
  SELECT b.f1
  FROM db2.t2 b
);
  1. I also find it curious that most formatted lines seem to begin with a space.
#setting       +N  +T  +S  N+  T+  S+
kw_and         1   0   0   0   0   0
kw_comma       1   0   0   0   0   0
kw_from        1   0   0   0   0   0
kw_full_join   1   0   0   0   0   0
kw_groupby     1   0   0   0   0   0
kw_having      1   0   0   0   0   0
kw_inner_join  1   0   0   0   0   0
kw_left_join   1   0   0   0   0   0
kw_on          1   0   0   0   0   0
kw_or          1   0   0   0   0   0
kw_orderby     1   0   0   0   0   0
kw_right_join  1   0   0   0   0   0
kw_select      1   0   0   0   0   0
kw_semicolon   0   0   0   2   0   0
kw_union       1   0   0   0   0   0
kw_union_all   1   0   0   0   0   0
kw_where       1   0   0   0   0   0

Using:
commit 6ea4a5d
Author: [email protected] [email protected]
Date: Sat Feb 23 20:08:49 2013 +0200

~/.fsqlf/ support under Windows

~/.fsqlf/ support would be useful in Windows too.

ifndef _WIN32

 const char *home_dir = getenv("HOME");

else

 const char *home_dir = getenv("USERPROFILE");

endif

After formatting INNER JOIN turn into JOIN

Thank you for beautified SQL queries.

When formatting query with INNER JOIN, keyword INNER disappears.

Example:

select *
from a
inner join b
on a.a = b.b

SELECT *
FROM a
JOIN b
ON a.a=b.b

Can you, please, direct me how can I keep INNER keyword in formatted queries?

bits/libc-header-start.h: No such file or directory

System:

$ lsb_release -d
Description:    Ubuntu 18.04.1 LTS

Steps to reproduce

  1. clone this repository
  2. cd fsqlf directory
  3. run make, output:
$ make
mkdir -p builds/make-linux/lib_fsqlf/conf_file/
mkdir -p builds/make-linux/lib_fsqlf/formatter/
mkdir -p builds/make-linux/lib_fsqlf/kw/
mkdir -p builds/make-linux/lib_fsqlf/lex/
mkdir -p builds/make-linux/utils/queue/
mkdir -p builds/make-linux/utils/stack/
mkdir -p builds/make-linux/utils/string/
mkdir -p builds/make-linux/cli/
gcc -o builds/make-linux/cli/main.o -c cli/main.c -std=c99 -Wall -pedantic-errors -g -Iinclude -m32
In file included from include/lib_fsqlf.h:5:0,
                 from cli/main.c:1:
/usr/include/stdio.h:27:10: fatal error: bits/libc-header-start.h: No such file or directory
 #include <bits/libc-header-start.h>
          ^~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
makefile:118: recipe for target 'builds/make-linux/cli/main.o' failed
make: *** [builds/make-linux/cli/main.o] Error 1

Following the README.md (i.e. installing wx and setting up the link) doesn't help.

Location of formatting.conf

Hi,

First, thank you for fsqlf. I have been looking for a command line tool to format SQL for a while and fsqlf is the best open source one I have found so far.

It seems fsqlf looks for formatting.conf in the current directory so I cannot simply add the directory it is in to PATH and expect it to work. Would be great if it looked in the current directory and if the file is not found then it looks in the directory in which the executable is located.

Thanks, Rohit

add correction of formatting

An unnecessary space is added. Example: SUM ( count ) - (error in mysql), must: SUM( count ).
Fix:

if( *text == '(' )
     r.space = 0;
else
     r.space = 1;

and add param "char* text" in static struct fsqlf_spacing calculate_spacing_pure.
Result:

static struct fsqlf_spacing calculate_spacing_pure(
    struct fsqlf_spacing afterspacing_of_prev,
    unsigned short int isword_of_prev,
    struct fsqlf_spacing beforespacing_of_current,
    unsigned short int isword_of_current,
    int global_indent_level,
   char* text)
{
    /* Combine spacings of adjacent words (previous and current).
        Combinations are done in two ways:
            - take MAX
            - use only current words settings
            (one more option could be to
            first print previous word's 'after' spacing,
            then print current word's 'before' spacing, but this could/would
            result in trailing spaces on a line)
        Decision, which of them to use, is made so:
            There are 3 types of spacings.
            They are ranked this way: space-1, indentation-2, new line-3.
            If current word has some non-zero spacing setting,
            then for spacings of lower ranks use conf only from current word.
        Rationale for such logic:
            If word has in its settings new-line=1 and indent/spaces=0,
            then there is expectation that keyword will be
            at the start of the line, no matter what previous fsqlf_kw_get setting
            for indentation after it was.
            (except for global indent level, because of subselect)
    */
    struct fsqlf_spacing r; // result to be built


    r.new_line = max_2args_(afterspacing_of_prev.new_line, beforespacing_of_current.new_line);

    r.indent = max_or_current(
            afterspacing_of_prev.indent
            , beforespacing_of_current.indent
            , beforespacing_of_current.new_line>1);
    r.indent += r.new_line ? global_indent_level : 0;

    r.space = max_or_current(
            afterspacing_of_prev.space
            , beforespacing_of_current.space
            , beforespacing_of_current.new_line || beforespacing_of_current.indent);


    // adjacent words MUST have some spacing
    if (!r.new_line && !r.indent && !r.space &&
        isword_of_prev && isword_of_current) {

		// 2017-07-04 victor.marquardt CHANGE:
		// Spacing after some keywords are not needed
		// Example: SUM()
		// Before changes: r.space = 1;
		if( *text == '(' )
			r.space = 0;
		else
			r.space = 1;
    }

    return r;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.