question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Compare two columns inside filter

See original GitHub issue

Hello! Is it possible compare two columns inside filter?

I would like do something like that:

[...] filter: { column1: { greaterThanOrEqualTo: column2} } [..]

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:3
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
jefbarncommented, Nov 22, 2019

FWIW, I got around this problem by using the new makeAddPgTableConditionPlugin to add a new custom filter clause that included my comparison operation. Edit, here’s some code for reference:

import { makeAddPgTableConditionPlugin } from 'graphile-utils'
import Maybe from 'graphql/tsutils/Maybe'

export const CustomFilterPlugin = makeAddPgTableConditionPlugin(
  'graphql',
  'ncsr',
  'recurring',
  build => ({
    description: 'Filters the list to NCSRs that use recurring dates.',
    type: build.graphql.GraphQLBoolean
  }),
  (value, helpers, build) => {
    const { sql, sqlTableAlias } = helpers
    const recurrencePatternIdent = sql.identifier('recurrence_pattern')
    const startTimeIdent = sql.identifier('scheduled_start_time')
    const endTimeIdent = sql.identifier('requested_date_of_completion')

    const onceOrSameDay = sql.fragment`
      ${sqlTableAlias}.${recurrencePatternIdent} = 'Once' OR
      date(${sqlTableAlias}.${startTimeIdent}) = date(${sqlTableAlias}.${endTimeIdent})
    `
    if ((value as Maybe<boolean>) === true) {
      return sql.fragment`NOT (${onceOrSameDay})`
    } else if ((value as Maybe<boolean>) === false) {
      return onceOrSameDay
    } else {
      return null
    }
  }
)
1reaction
mattbretlcommented, Oct 7, 2019

Tentatively yes, though I would publish it as a separate package with a dependency on this plugin. For v2, I plan to move several features into separate plugins.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Compare two columns and extract differences - Excel 365
Compare values between two columns and filter values existing in only one column. This article demonstrates formulas that extract values ...
Read more >
How to Compare Two Columns in Excel (for matches ...
In this tutorial, I'll show you various ways to compare two columns in Excel. The techniques shown can be used to find/highlight matches...
Read more >
Excel: Compare two columns for matches and differences
In this tutorial, we will explore several techniques to compare two columns in Excel and find matches and differences between them.
Read more >
How to compare values in two columns in custom filters
Hey! I faced this issue, when I need to compare every value from one column with every value in the second column and...
Read more >
How to compare the content of 2 columns in functions on object?
You can create a new boolean column in your object's underlying dataset that is true if colOne and colTwo match, and false otherwise....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found