Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Carlson committed Jul 4, 2018
1 parent 9816e21 commit 8a5e134
Show file tree
Hide file tree
Showing 22 changed files with 15 additions and 35 deletions.
4 changes: 2 additions & 2 deletions src/array-to-connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ function arrToConnection(data, sqlAST) {
pageInfo.endCursor = last(edges).cursor
}
return { edges, pageInfo, _paginated: true }
} else if (sqlAST.orderBy || (sqlAST.junction && sqlAST.junction.orderBy)) {
}
if (sqlAST.orderBy || (sqlAST.junction && sqlAST.junction.orderBy)) {
let offset = 0
if (idx(sqlAST, _ => _.args.after)) {
offset = cursorToOffset(sqlAST.args.after) + 1
Expand All @@ -89,4 +90,3 @@ function recurseOnObjInData(dataObj, astChild) {
dataObj[astChild.fieldName] = arrToConnection(dataObj[astChild.fieldName], astChild)
}
}

4 changes: 1 addition & 3 deletions src/define-object-shape.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ function _defineObjectShape(parent, prefix, node) {
if (child.sqlBatch) {
fieldDefinition[child.sqlBatch.parentKey.fieldName + suffix] = prefixToPass + child.sqlBatch.parentKey.as
} else if (idx(child, _ => _.junction.sqlBatch)) {
fieldDefinition[child.junction.sqlBatch.parentKey.fieldName + suffix] =
prefixToPass + child.junction.sqlBatch.parentKey.as
fieldDefinition[child.junction.sqlBatch.parentKey.fieldName + suffix] = prefixToPass + child.junction.sqlBatch.parentKey.as
} else {
const definition = _defineObjectShape(node, prefixToPass, child)
fieldDefinition[child.fieldName + suffix] = definition
Expand All @@ -95,4 +94,3 @@ function _defineObjectShape(parent, prefix, node) {
}
return fieldDefinition
}

1 change: 0 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,3 @@ joinMonster.getNode = getNode
// expose the package version for debugging
joinMonster.version = require('../package.json').version
export default joinMonster

7 changes: 4 additions & 3 deletions src/query-ast-to-sql-ast/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ export function populateASTNode(queryASTNode, parentTypeNode, sqlASTNode, namesp

// is this a table in SQL?
if (
!field.jmIgnoreTable &&
TABLE_TYPES.includes(gqlType.constructor.name)
!field.jmIgnoreTable
&& TABLE_TYPES.includes(gqlType.constructor.name)
&& config.sqlTable
) {
if (depth >= 1) {
Expand Down Expand Up @@ -501,7 +501,8 @@ function toClumsyName(keyArr) {
function keyToASTChild(key, namespace) {
if (typeof key === 'string') {
return columnToASTChild(key, namespace)
} else if (Array.isArray(key)) {
}
if (Array.isArray(key)) {
const clumsyName = toClumsyName(key)
return {
type: 'composite',
Expand Down
1 change: 0 additions & 1 deletion src/resolve-unions.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,3 @@ export default function resolveUnions(data, sqlAST) {
}
}
}

3 changes: 1 addition & 2 deletions src/stringifiers/dialects/pg.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ const dialect = module.exports = {

const tempTable = `FROM (VALUES ${batchScope.map(val => `(${val})`)}) temp("${node.junction.sqlBatch.parentKey.name}")`
tables.push(tempTable)
const lateralJoinCondition =
`"${node.junction.as}"."${node.junction.sqlBatch.thisKey.name}" = temp."${node.junction.sqlBatch.parentKey.name}"`
const lateralJoinCondition = `"${node.junction.as}"."${node.junction.sqlBatch.thisKey.name}" = temp."${node.junction.sqlBatch.parentKey.name}"`

const lateralJoinOptions = { joinCondition: lateralJoinCondition, joinType: 'LEFT' }
if (node.where || node.orderBy) {
Expand Down
7 changes: 3 additions & 4 deletions src/stringifiers/dispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ export default async function stringifySqlAST(topNode, context, options) {
if (!selections.length) return ''

// put together the SQL query
let sql = 'SELECT\n ' +
selections.join(',\n ') + '\n' +
tables.join('\n')
let sql = 'SELECT\n '
+ selections.join(',\n ') + '\n'
+ tables.join('\n')

wheres = filter(wheres)
if (wheres.length) {
Expand Down Expand Up @@ -291,4 +291,3 @@ function sortKeyToOrderColumns(sortKey, args) {
}
return orderColumns
}

7 changes: 3 additions & 4 deletions src/stringifiers/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ function sortKeyToWhereCondition(keyObj, descending, sortTable, dialect) {
sortValues.push(maybeQuote(keyObj[key], name))
}
const operator = descending ? '<' : '>'
return name === 'oracle' ?
recursiveWhereJoin(sortColumns, sortValues, operator) :
`(${sortColumns.join(', ')}) ${operator} (${sortValues.join(', ')})`
return name === 'oracle'
? recursiveWhereJoin(sortColumns, sortValues, operator)
: `(${sortColumns.join(', ')}) ${operator} (${sortValues.join(', ')})`
}

function recursiveWhereJoin(columns, values, op) {
Expand All @@ -216,4 +216,3 @@ function _recursiveWhereJoin(columns, values, op, condition) {
condition = `(${column} ${op} ${value} OR (${column} = ${value} AND ${condition}))`
return _recursiveWhereJoin(columns, values, op, condition)
}

3 changes: 1 addition & 2 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ function validate(rows) {
// its supposed to be an array of objects
if (Array.isArray(rows)) return rows
// a check for the most common error. a lot of ORMs return an object with the desired data on the `rows` property
else if (rows && rows.rows) return rows.rows
if (rows && rows.rows) return rows.rows

throw new Error(
`"dbCall" function must return/resolve an array of objects where each object is a row from the result set.
Expand Down Expand Up @@ -226,4 +226,3 @@ export async function compileSqlAST(sqlAST, context, options) {
}
return { sql, shapeDefinition }
}

1 change: 0 additions & 1 deletion test/_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ export function errCheck(t, errors) {
}
t.is(errors, undefined)
}

1 change: 0 additions & 1 deletion test/columns.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,4 +363,3 @@ test('it should handle raw SQL expressions', async t => {
errCheck(t, errors)
t.is(data.user.fullName.split(' ')[1].toUpperCase(), data.user.capitalizedLastName)
})

1 change: 0 additions & 1 deletion test/fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,3 @@ test('it should handle duplicate of a field recursively', async t => {
}
t.deepEqual(expect, data.user)
})

1 change: 0 additions & 1 deletion test/filteringInNestedBatches.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,3 @@ test('it should get user 1 with comments and particular posts with active commen

t.deepEqual(expect, data)
})

1 change: 0 additions & 1 deletion test/identify.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,3 @@ test('it should handle composite keys', async t => {
}
t.deepEqual(expect, data)
})

1 change: 0 additions & 1 deletion test/junctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,3 @@ test('should handle data from the junction table', async t => {
}
t.deepEqual(expect, data)
})

1 change: 0 additions & 1 deletion test/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,3 @@ test('it sould handle order on many-to-many', async t => {
}
t.deepEqual(expect, data)
})

1 change: 0 additions & 1 deletion test/pagination/keyset-paging.js
Original file line number Diff line number Diff line change
Expand Up @@ -785,4 +785,3 @@ test('should handle an interface type', async t => {
}
t.deepEqual(expect, data.user.writtenMaterial)
})

1 change: 0 additions & 1 deletion test/pagination/limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,3 @@ test('should handle limit for many-to-many', async t => {
}
t.deepEqual(expect, data)
})

1 change: 0 additions & 1 deletion test/pagination/offset-paging.js
Original file line number Diff line number Diff line change
Expand Up @@ -745,4 +745,3 @@ test('should handle an interface type', async t => {
}
t.deepEqual(expect, data.user.writtenMaterial)
})

1 change: 0 additions & 1 deletion test/relations.js
Original file line number Diff line number Diff line change
Expand Up @@ -641,4 +641,3 @@ test('should handle a correlated subquery', async t => {
}
t.deepEqual(expect, data)
})

1 change: 0 additions & 1 deletion test/relay.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,4 +372,3 @@ test('should handle fragments recursively', async t => {
}
t.deepEqual(expect, data)
})

1 change: 0 additions & 1 deletion test/union.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,3 @@ test('it should an interface type', async t => {
}
t.deepEqual(expect, data)
})

0 comments on commit 8a5e134

Please sign in to comment.