title: What does the "SQLite3::SQLException: near ".": syntax error" mean?
body: <p>I'm writing an ORM (object relational model) and I've been stuck on this error message for a while now. I did narrow it down to the update and the save method (I have a feeling that the error most likely is in the update method specifically), but I can't figure out where the syntax error is happening.</p>
  
  <p>Here is the error message:</p>
  
  <pre><code>SQLite3::SQLException: near ".": syntax error
  from /Users/karenlee/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/sqlite3-1.4.1/lib/sqlite3/database.rb:147:in `initialize'
  </code></pre>
  
  <p>And here is my ORM:</p>
  
  <pre><code>require_relative 'questions_database'
  
  class User
    attr_reader :id
    attr_accessor :fname, :lname
  
    # displays all users
    def self.all
      users = QuestionsDatabase.instance.execute("SELECT * FROM users")
      users.map { | user_info | User.new(user_info) }
    end
  
    # finds a user by their primary id
    def self.find_by_id(id)
      found_user = QuestionsDatabase.instance.execute(&lt;&lt;-SQL, id: id)
        SELECT
          users.*
        FROM
          users
        WHERE
          users.id = :id
      SQL
      found_user.nil? ? nil : User.new(found_user.first)
    end
  
    # finds a user by their first and last name
    def self.find_by_name(fname, lname)
      name = {fname: fname, lname: lname}
      found_user = QuestionsDatabase.instance.execute(&lt;&lt;-SQL, name)
        SELECT
          users.*
        FROM
          users
        WHERE
          users.fname = :fname AND users.lname = :lname
      SQL
      found_user.nil? ? nil : User.new(found_user.first)
    end
  
    # creates a new user instance
    def initialize(options)
      @id, @fname, @lname = options.values_at('id', 'fname', 'lname')
    end
  
    # saves the user into the database (or updates when needed)
    def save
      if self.id
        update
      else  
        create
      end
    end
  
    private
    # helper method to update the database
    def update
      values = {id: id, fname: fname, lname: lname}
      QuestionsDatabase.instance.execute(&lt;&lt;-SQL, values)
        UPDATE
          users
        SET
          users.fname = :fname, users.lname = :lname
        WHERE
          users.id = :id
      SQL
    end
  
    # helper method to create a row in the database
    def create
      name = {fname: fname, lname: lname}
      QuestionsDatabase.instance.execute(&lt;&lt;-SQL, name)
        INSERT INTO
          users (fname, lname)
        VALUES
          (:fname, :lname)
      SQL
      self.id = QuestionsDatabase.instance.last_insert_row_id
    end
  end
  </code></pre>
  
  <p>Here's the QuestionsDatabase class if you need it:</p>
  
  <pre><code>require 'sqlite3'
  require 'singleton'
  
  class QuestionsDatabase &lt; SQLite3::Database
      include Singleton  
  
      def initialize
        super('questions.db')
        self.type_translation = true
        self.results_as_hash = true
      end
  end
  </code></pre>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I've found where my error was! It turned out that I should have just been saying <code>fname = :fname, lname = :lname</code> instead of saying <code>users.fname = :fname, users.lname = :lname</code>. But I'm still unsure as to why this is. It seems like the update statement doesn't like it when I don't use aliases, but some more explanation on this would be great!</p>