-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get query's tables and columns #3
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
16ce451
WIP
tsmacdonald 054f5e2
Set up build for Java
tsmacdonald 6806558
Add ASTWalker.java!
tsmacdonald 13d7f4a
Almost got SqlVisitor worked out
tsmacdonald 9f01e14
Add SqlVisitor and ASTWalker; use for query->columns
tsmacdonald 27fc003
Cleanup
tsmacdonald 981b476
Build before testing on CI
tsmacdonald 9ea7361
Build before checking on CI
tsmacdonald 7a3164a
Put Java file in the right spot :open_mouth:
tsmacdonald 1efb3cc
Refactor to use a Clojure map + callbacks
tsmacdonald c2a178c
Add some basic build scripts
tsmacdonald e5dfbea
Update docs
tsmacdonald 7e7cbeb
atom->transient
tsmacdonald 18c5e0d
Make ASTWalker more robust/foolproof
tsmacdonald 9af463e
Back to atoms
tsmacdonald File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,29 @@ Macaw is a limited Clojure wrapper for | |
[JSqlParser](https://github.com/JSQLParser/JSqlParser). Similar to its parrot | ||
namesake, it's intelligent, can be taught to speak SQL, and has many colors | ||
(supports many dialects). | ||
|
||
|
||
## Building | ||
|
||
To build a local JAR, use | ||
|
||
``` | ||
./bin/build-jar | ||
``` | ||
|
||
This will create a JAR in the `target` directory. | ||
|
||
## Working with the Java files | ||
|
||
To compile the Java files, use | ||
|
||
``` | ||
./bin/compile-java | ||
``` | ||
|
||
If you're working on Macaw and make changes to a Java file, you must: | ||
|
||
1. Recompile | ||
2. Restart your Clojure REPL | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there no way to improve this workflow in 2024? 😢 (outside scope of this PR) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. possibly with the right ns refresh, but I haven't worked it out :( |
||
|
||
for the changes to take effect. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
if [[ -n "${TRACE-}" ]]; then | ||
set -o xtrace | ||
fi | ||
|
||
if [ $# -ge 1 ] && [[ "$1" =~ ^-*h(elp)?$ ]]; then | ||
echo 'Usage: ./bin/build-jar | ||
|
||
Build a JAR | ||
|
||
' | ||
exit | ||
fi | ||
|
||
# Ensure we're in the project root | ||
cd "$(dirname "$0")"/.. | ||
|
||
main() { | ||
clj -T:build jar | ||
} | ||
|
||
main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
if [[ -n "${TRACE-}" ]]; then | ||
set -o xtrace | ||
fi | ||
|
||
if [ $# -ge 1 ] && [[ "$1" =~ ^-*h(elp)?$ ]]; then | ||
echo 'Usage: ./bin/java-compile | ||
|
||
Compiles all the Java files used in the project so that they can be used in local Clojure development. To build a JAR, use ./build-jar instead. | ||
|
||
' | ||
exit | ||
fi | ||
|
||
# Ensure we're in the project root | ||
cd "$(dirname "$0")"/.. | ||
|
||
main() { | ||
clj -T:build compile | ||
} | ||
|
||
main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
;; Further info: https://clojure.org/guides/tools_build#_mixed_java_clojure_build | ||
|
||
(ns build | ||
(:require | ||
[clojure.java.shell :as sh] | ||
[clojure.string :as str] | ||
[clojure.tools.build.api :as b])) | ||
|
||
(def lib 'metabase/macaw) | ||
|
||
(def major-minor-version "0.1") | ||
|
||
(defn commit-number [] | ||
(or (-> (sh/sh "git" "rev-list" "HEAD" "--count") | ||
:out | ||
str/trim | ||
parse-long) | ||
"9999-SNAPSHOT")) | ||
tsmacdonald marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
(def version (str major-minor-version \. (commit-number))) | ||
(def target "target") | ||
(def class-dir (format "%s/classes" target)) | ||
|
||
(def jar-file (format "target/%s-%s.jar" (name lib) version)) | ||
|
||
(def basis (delay (b/create-basis {:project "deps.edn"}))) | ||
|
||
(defn clean [_] | ||
(b/delete {:path target})) | ||
|
||
(defn compile [_] | ||
(b/javac {:src-dirs ["java"] | ||
:class-dir class-dir | ||
:basis @basis | ||
:javac-opts ["--release" "11"]})) | ||
|
||
(defn jar [_] | ||
(compile nil) | ||
(b/write-pom {:class-dir class-dir | ||
:lib lib | ||
:version version | ||
:basis @basis | ||
:src-dirs ["src"]}) | ||
(b/copy-dir {:src-dirs ["src" "resources"] | ||
:target-dir class-dir}) | ||
(b/jar {:class-dir class-dir | ||
:jar-file jar-file})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be expanded once I set up Clojars.