Giter VIP home page Giter VIP logo

qolor's Introduction

Qolor

An atom package to color your SQL queries!

Qolor applies semantic highlighting to your SQL queries by matching tables to their aliases.

Qolor in action!

All colors of tables are deterministic and based on their name. They will be the same on any Atom editor anywhere!

Qolor has a few outstanding issues but it's usable and I want to launch it in the spirit of MVP. I say it's usable because it doesn't throw errors or pop up the inspector. If you see it doing this please report ASAP. Please feel free to create issues of broken coloring cases with screen shots or text samples (remember to check out the TODO below and the open issues).

Installation

apm install qolor

Settings

Two stylistic flavors. Underline (default) or a border box. The border box is more of a placeholder for now. I only built it to facilitate pull requests etc.

Optional Keymap To Toggle

Go to Atom -> Open Your Keymap and enter the following:

'atom-workspace':
  'ctrl-alt-q': 'qolor:toggle'

# Careful, don't override your existing 'atom-workspace'!

How to Auto Associate File Types in Atom

Go to Atom -> 'Init Script...' and add in:

# This example associates all mustache files with 'SQL (Mustache)'.
atom.workspace.observeTextEditors (editor) ->
  if editor.getPath()?.match(/\.mustache$/)
    editor.setGrammar(atom.grammars.grammarForScopeName('source.sql.mustache'))

Prior Art / Related Works

I got the idea for Qolor while working with a large query. We all play a frustrating game of connect the dots while mentally parsing ("grokking") aliases to their tables. Colors can help you hunt down the aliases.

Later a friend pointed out that a lot of related work in the area of "semantic highligting" already exists! Although, I have yet to find one that does this semantic highlighting for SQL in this table to alias manner. Let me know if it does!

Here are some of the related links:

How it works

Qolor uses the language-sql grammar built into Atom (actually it evolved from textmate/sublime). The code performs a double pass. First pass for the table names and second pass for the aliases.

I don't know of any SQL parsers in node usable for this project.

The code is ugly. language-sql suffices for syntax coloring, but it's tokens aren't always accurate. I try to make a layer of rules on top.

It should work for most cases, but please report any issues.

Your performance should be unaffected because qolor utilizes the debounced api for observing the grammar and because well, computers are fast.

TODO

  • [BUG] Cartesian products / cross joins don't work. They are particularly troublesome without aliases. This is due to existing limitations in the language-sql grammar. I have an idea of how to address this but prefer to see if anyone has a suggestion of how to integrate a real parser.

  • Custom styling of underline / border.

  • Better handling of colors. Possibly hue blending etc. Leverage theme information. I still want these to be deterministic but for example, perhaps a marginal shift of the colors to play nicely with the themes. Pull requests?

  • Jump to and from matching tables and aliases under cursor.

  • List number of references in the status bar.

  • Add qolor to the minimap.

  • Stats report of all tables or projected fields. Maybe visual like a minimap? Query execution plans etc.

  • Some treatment of matching or applicable fields names?

My other Atom package :)

qolor's People

Contributors

davidlgoldberg avatar

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.