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.

OrderBy not returning any transactions at all

See original GitHub issue

Do you want to request a feature or report a bug?

This is a bug. I notice quite a few open OrderBy related issues, but this one seems to be even more opaque. However, I can see it’s not happening to other people, so I suspect it’s at least partially related to my setup. But my setup is very normal.

What is the current behavior?

Adding an orderBy clause to any firestoreConnect component causes no data to be loaded:

export default compose(
  connect(mapStateToProps, mapDispatchToProps),
  firestoreConnect((props) => {
    return [
      {
        collection: 'categories',
        where: [['uid', '==', props.uid],],
        orderBy: [['name', 'asc']] // doesn't work
        // orderBy: ['name'] // doesn't work
        // orderBy: 'name' // Nope

      }
    ]
  }),
)(CategoryChooser)

What is the expected behavior?

Elements should be returned, preferably in the requested order.

Which versions of dependencies, and which browser are affected by this issue? Did this work in previous versions or setups?

It’s behaving the same in 0.5.7 and 0.6.0-alpha2, under firefox on Fedora Linux 28.

The JS project was created with create-react-app. Here are the deps from my package.json:

  "dependencies": {
    "firebase": "^5.3.1",
    "moment": "^2.22.2",
    "object-hash": "^1.3.0",
    "papaparse": "^4.6.0",
    "react": "^16.4.2",
    "react-dom": "^16.4.2",
    "react-redux": "^5.0.7",
    "react-redux-firebase": "^2.1.7",
    "react-router-dom": "^4.3.1",
    "react-scripts": "^2.0.0-next.3e165448",
    "react-social-login-buttons": "^2.1.2",
    "redux": "^4.0.0",
    "redux-firestore": "^0.6.0-alpha.2",
    "redux-thunk": "^2.3.0"
  },

Steps to reproduce and if possible a minimal demo of the problem via codesandbox or similar.

I suspect there will be some back and forth on this, but my setup is pretty generic. I’m composing my component as shown above, and I have my store configured as follows

import firebaseConfig from '../firebaseConfig.js'
import { createStore, compose, applyMiddleware } from 'redux'
import thunk from "redux-thunk"
import { reactReduxFirebase, getFirebase } from 'react-redux-firebase'
import { reduxFirestore } from 'redux-firestore'
import { initialState, rootReducer } from './reducers'

import firebase from 'firebase/app'
import 'firebase/auth'
import 'firebase/firestore'

firebase.initializeApp(firebaseConfig)
const fs = firebase.firestore()


const ReactReduxFirebaseConfig = {
  userProfile: 'users',
  useFirestoreForProfile: true,
  enableLogging: true,
}

const enhancers = [
  reactReduxFirebase(firebase, ReactReduxFirebaseConfig),
  reduxFirestore(firebase)
]

const composedEnhancers = compose(
  ...enhancers
)

const store = createStore(rootReducer, initialState, composedEnhancers)


export default store

For completeness, my reducers are defined correctly (everything works unless I orderBy):

import { combineReducers } from 'redux'
import { firebaseReducer } from 'react-redux-firebase'
import { firestoreReducer } from 'redux-firestore'
import { account_reducer } from './accounts'
import { transaction_reducer } from './transactions'

export const initialState = {}


export const rootReducer = combineReducers({
  firebase: firebaseReducer,
  firestore: firestoreReducer,
  accounts: account_reducer,
  transactions: transaction_reducer
})

There are no error messages in the console. I disabled redux-dev-tools to make sure it wasn’t conflicting somehow, but when it was on, it was showing an uninformative error returned from firebase:

errors: {
      byQuery: {
        'categories?where=uid:==:PijZAm394pMu24jSjAM2yVLfPLZ2': {
          code: 'failed-precondition',
          name: 'FirebaseError'
        }
      },
      allIds: [
        'categories?where=uid:==:PijZAm394pMu24jSjAM2yVLfPLZ2'
      ]
    }

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
karltaylorcommented, Aug 7, 2018

@prescottprue Bingo!

Putting reduxFirestore first logged the error. It does seem to be getting overwritten by reactReduxFirebase

2reactions
dusty-phillipscommented, Aug 7, 2018

I had enabled logErrors and not seen anything in the console, but that was probably due to not looking correctly. It was getting pretty late at night when I gave up. 😉 I think all this really needs is a documentation update – more clarity on what logErrors does and maybe a faq entry on indexes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does including an orderBy statement not return all records?
I'm guessing it has something to do with the index and the data not being adjacent to each other. But without any visibility...
Read more >
OrderBy on ISearchQuery does not return the results properly ...
Taking advantage of the OrderBy of ISearchQuery doesn't return the items properly sorted and in some cases doesn't return items at all. E.g:...
Read more >
SELECT - ORDER BY Clause (Transact-SQL) - Microsoft Learn
The order in which rows are returned in a result set are not guaranteed unless an ORDER BY clause is specified. Determine the...
Read more >
Transaction commands - Cypher Manual - Neo4j
SHOW TRANSACTIONS; Syntax; Listing all transactions; Listing transactions ... The command SHOW TRANSACTIONS returns only the default output.
Read more >
$sort (aggregation) — MongoDB Manual
Sorts all input documents and returns them to the pipeline in sorted order. ... MongoDB does not store documents in a collection in...
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