Skip to content
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

[3.x] Remove problematic unused code when formatting SQL #924

Merged
merged 1 commit into from
Jul 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions resources/js/screens/queries/preview.vue
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
<script type="text/ecmascript-6">
import _ from 'lodash';
import sqlFormatter from "sql-formatter";
import hljs from 'highlight.js/lib/highlight';
import sql from 'highlight.js/lib/languages/sql';
import StandardSqlFormatter from 'sql-formatter/src/languages/StandardSqlFormatter';

export default {
data(){
return {
entry: null,
batch: [],
sqlFormatter: new StandardSqlFormatter({}),
};
},

methods:{
formatSQL(sql, params) {
return sqlFormatter.format(sql, {
params: _.map(params, param => _.isString(param) ? '"'+param+'"' : param)
});
},

highlightSQL() {
this.$nextTick(() => {
hljs.registerLanguage('sql', sql);
Expand Down Expand Up @@ -64,7 +56,7 @@
<div class="card mt-5">
<div class="card-header"><h5>Query</h5></div>

<pre class="code-bg p-4 mb-0 text-white" ref="sqlcode">{{formatSQL(slotProps.entry.content.sql, slotProps.entry.content.bindings)}}</pre>
<pre class="code-bg p-4 mb-0 text-white" ref="sqlcode">{{sqlFormatter.format(slotProps.entry.content.sql)}}</pre>
</div>
</div>
</preview-screen>
Expand Down