title: Room SQLite query doesn't return any results, even though there are rows in the database that match
body: <p>I am using this command to get data from a Room database: </p>
  
  <p><code>select * from location_search_results where searchQuery = "wilmington"</code></p>
  
  <p>Here is what the database looks like:</p>
  
  <p><a href="https://i.stack.imgur.com/GXT4b.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GXT4b.png" alt="enter image description here"></a></p>
  
  <p>And here are the search results:
  <a href="https://i.stack.imgur.com/0RTHE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0RTHE.png" alt="enter image description here"></a></p>
  
  <p>I have verified that the name of the table is correct and everything, and there's no spelling errors that I can find, so why would this query not return any of the three rows that it should match?</p>
  
  <p>EDIT for code:</p>
  
  <p>The source code is publicly available <a href="https://github.com/jollygreenegiant/SimpleWeather/tree/mvvm" rel="nofollow noreferrer">here</a>, I am working in the <code>mvvm</code> branch, so if you pull it, make sure you're there.  Below are the relevant classes:</p>
  
  <p>LocationSearchResponse.kt:</p>
  
  <pre><code>@Entity(tableName = "location_search_results")
  class LocationSearchResponse(
          @ColumnInfo(name = "type")
          val type: String,
          @TypeConverters(DataConverter::class)
          @SerializedName("query")
          val searchQuery: List&lt;String&gt;,
          @TypeConverters(DataConverter::class)
          val features: List&lt;Feature&gt;,
          @ColumnInfo(name = "attribution")
          val attribution: String
  ) {
      @PrimaryKey(autoGenerate = true)
      var id: Int = 0
  }
  </code></pre>
  
  <p>LocationSearchRepositoryImpl.kt:</p>
  
  <pre><code>class LocationSearchRepositoryImpl (
          private val locationResponseDao: LocationResponseDao,
          private val locationNetworkDataSource: LocationNetworkDataSource
  ): LocationSearchRepository {
  
      init {
          locationNetworkDataSource.downloadedLocationSearchResults.observeForever { locationResults -&gt;
              persistFetchedLocations(locationResults)
          }
      }
  
      // update search data in db if necessary, then return the data that was searched for.
      override suspend fun searchForLocation(query: String): LiveData&lt;out LocationSearchResponse&gt; {
          return withContext(Dispatchers.IO) {
              initSearch(query)
              return@withContext locationResponseDao.searchForLocation(query)
          }
      }
  
      // if a fetch is necessary (query has not already been searched), fetch search results
      private suspend fun initSearch(query: String) {
          if (isFetchLocationResultsNeeded(query))
              fetchLocationResults(query)
      }
  
      private fun isFetchLocationResultsNeeded(query: String) : Boolean {
          // get the cached results.  If it's null, return true because it needs to be updated
          val cachedResults = locationResponseDao.searchForLocationNonLive(query.toLowerCase())
  
          if (cachedResults == null) return true
  
          // if the results are empty, it needs to be fetched, else it doesn't
          return cachedResults.features.isEmpty()
      }
  
      private suspend fun fetchLocationResults(query: String) {
          locationNetworkDataSource.fetchLocationSearchResults("mapbox.places", query)
      }
  
      private fun persistFetchedLocations(fetchedLocationResults: LocationSearchResponse) {
          GlobalScope.launch(Dispatchers.IO) {
              locationResponseDao.upsert(fetchedLocationResults)
          }
      }
  }
  </code></pre>
  
  <p>LocationResponseDao.kt:</p>
  
  <pre><code>@Dao
  interface LocationResponseDao {
  
      // update or insert existing entry if there is a conflict when adding to db
      @Insert(onConflict = OnConflictStrategy.REPLACE)
      fun upsert(locationResults: LocationSearchResponse)
  
      @Query("select * from location_search_results WHERE searchQuery = :query")
      fun searchForLocation(query: String): LiveData&lt;LocationSearchResponse&gt;
  
      @Query("select * from location_search_results WHERE searchQuery = :query")
      fun searchForLocationNonLive(query: String): LocationSearchResponse?
  
      @Query("delete from location_search_results")
      fun nukeTable()
  }
  </code></pre>
  
  <p>and ChooseCityFragment.kt:</p>
  
  <pre><code>class ChooseCityFragment : ScopedFragment(), KodeinAware {
  
      override val kodein by closestKodein()
      private val locationViewModelFactory: LocationResponseViewModelFactory by instance()
      private val weatherResponseViewModelFactory: WeatherResponseViewModelFactory by instance()
  
      private lateinit var locationViewModel: LocationResponseViewModel
      private lateinit var weatherViewModel: WeatherResponseViewModel
  
      override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
                                savedInstanceState: Bundle?): View? {
  
          setupViews()
  
          // Inflate the layout for this fragment
          return inflater.inflate(R.layout.choose_city_fragment, container, false)
      }
  
      override fun onActivityCreated(savedInstanceState: Bundle?) {
          super.onActivityCreated(savedInstanceState)
          locationViewModel = ViewModelProviders.of(this, locationViewModelFactory)
                  .get(LocationResponseViewModel::class.java)
  
          weatherViewModel = ViewModelProviders.of(this, weatherResponseViewModelFactory)
                  .get(WeatherResponseViewModel::class.java)
  
          updateToolbar()
      }
  
      fun updateToolbar() {
          (activity as? AppCompatActivity)?.supportActionBar?.title = "Choose Location"
          (activity as? AppCompatActivity)?.supportActionBar?.subtitle = null
      }
  
      fun bindUI() = launch {
          val locationResults = locationViewModel.locationResponse
          val owner = viewLifecycleOwner
  
          locationResults.observe(owner, Observer {
              if (it == null) return@Observer
  
              // TODO: set loading icon to GONE
  
              initRecyclerView(it.features.toLocationSearchResultListItem())
          })
      }
  
      fun setupViews() = launch {
          search_button.setOnClickListener {
              searchLocations()
              search_results_rv.adapter?.notifyDataSetChanged()
          }
      }
  
      // TODO: search text can not be more than 20 words or more than 256 characters.  Need to account for this
      fun searchLocations() = launch {
          val searchText = search_box.text.toString()
  
          if (searchText != "") {
              locationViewModel.searchLocation(search_box.text.toString())
              bindUI()
          } else
              Toast.makeText(context?.applicationContext, "Please enter a search term", Toast.LENGTH_SHORT).show()
      }
  
      private fun List&lt;Feature&gt;.toLocationSearchResultListItem() : List&lt;LocationSearchResultListItem&gt; {
          return this.map {
              LocationSearchResultListItem(it)
          }
      }
  
      private fun initRecyclerView(items: List&lt;LocationSearchResultListItem&gt;) {
          val groupAdapter = GroupAdapter&lt;ViewHolder&gt;().apply {
              addAll(items)
          }
  
          groupAdapter.notifyDataSetChanged()
  
          search_results_rv.apply {
              layoutManager = LinearLayoutManager(this@ChooseCityFragment.context)
              adapter = groupAdapter
          }
  
          groupAdapter.setOnItemClickListener { item, view -&gt;
              (item as? LocationSearchResultListItem)?.let {
                  refreshWeather(it.feature.coordinates[0], it.feature.coordinates[1])
              }
          }
      }
  
      private fun refreshWeather(latitude: Double, longitude: Double) = launch {
          weatherViewModel.refreshWeatherWithCoordinates(latitude, longitude)
      }
  }
  </code></pre>