Click here to Skip to main content
12,245,040 members (58,824 online)
Click here to Skip to main content
Articles » Database » Database » SQL Server » Downloads

Stats

114.3K views
21.5K downloads
110 bookmarked
Posted

SQLite Compare Utility

, 21 Feb 2015 LGPL3
Utility for comparing two SQLite database files for both structure and data
SQLiteCompare
gplex.exe
gplexx.frame
gppg.exe
license.lic
log4net.dll
Puzzle.SyntaxBox.NET3.5.dll
ShiftReduceParser.dll
SQLiteTurboDiff.suo
System.Data.SQLite.dll
AutomaticUpdates
Properties
Be.Windows.Forms.HexBox
HexBox.bmp
HexBox.snk
Thumbs.db
Design
Common
Properties
CreateTestDatabases
Properties
TestSchemaFiles
DiffControl
Properties
FastGrid
Properties
Liron.Windows.Forms
multipanel.ico
Thumbs.db
Design
Properties
Setup
appicon.ico
finish_banner.bmp
installer_banner.bmp
setup.nsi
Thumbs.db
uninstallicon.ico
SQLiteParser
sqlite.lex
sqlite.y
Properties
SQLiteTurbo
sqlite.syn
SQLiteTurbo.csproj.user
Properties
Resources
feedback2.png
feedback_non_selected_idea.png
feedback_non_selected_question.png
feedback_pressed.png
feedback_problem_non_selected.png
feedback_problem_selected.png
feedback_selected_idea.png
feedback_selected_question.png
normal_feedback_button.png
pressed_feedback_button.png
SVG
about.svg
accept.svg
app.svg
appicon.svg
bug.svg
check_updates.svg
close_comparison.svg
company_tagline.svg
compare.svg
copy_from_left_db.svg
copy_from_right_db.svg
edit_selected_difference.svg
feather.svg
feedback.svg
feedback_frame.svg
feedback_non_selected_idea.svg
feedback_non_selected_problem.svg
feedback_question.svg
feedback_selected_problem.svg
feedback_selected_question.svg
finish_page_banner.svg
free.svg
generate_script_left_to_right.svg
generate_script_right_to_left.svg
greenpinesoftware_logo.svg
home_screenshot.svg
installer_banner.svg
key.svg
lamp.svg
lamp_non_selected.svg
lamp_selected.svg
lock.svg
main_screen.svg
next_diff.svg
prev_diff.svg
question.svg
recycle_bin.svg
redo.svg
reject.svg
reorder_columns.svg
save_schema.svg
search.svg
smallbug.svg
sqlite_compare_logo.svg
sqlite_feather.svg
text2451.png
undo.svg
uninstall.svg
v_bullet.svg
UndoRedo
Properties
SQLiteCompareSetup.exe
gplex.exe
gplexx.frame
gppg.exe
license.lic
log4net.dll
Puzzle.SyntaxBox.NET3.5.dll
ShiftReduceParser.dll
SQLiteTurboDiff.suo
System.Data.SQLite.dll
HexBox.bmp
HexBox.snk
Thumbs.db
multipanel.ico
Thumbs.db
appicon.ico
finish_banner.bmp
installer_banner.bmp
setup.nsi
Thumbs.db
uninstallicon.ico
sqlite.lex
sqlite.y
sqlite.syn
SQLiteTurbo.csproj.user
feedback2.png
feedback_non_selected_idea.png
feedback_non_selected_question.png
feedback_pressed.png
feedback_problem_non_selected.png
feedback_problem_selected.png
feedback_selected_idea.png
feedback_selected_question.png
normal_feedback_button.png
pressed_feedback_button.png
about.svg
accept.svg
app.svg
appicon.svg
bug.svg
check_updates.svg
close_comparison.svg
company_tagline.svg
compare.svg
copy_from_left_db.svg
copy_from_right_db.svg
edit_selected_difference.svg
feather.svg
feedback.svg
feedback_frame.svg
feedback_non_selected_idea.svg
feedback_non_selected_problem.svg
feedback_question.svg
feedback_selected_problem.svg
feedback_selected_question.svg
finish_page_banner.svg
free.svg
generate_script_left_to_right.svg
generate_script_right_to_left.svg
greenpinesoftware_logo.svg
home_screenshot.svg
installer_banner.svg
key.svg
lamp.svg
lamp_non_selected.svg
lamp_selected.svg
lock.svg
main_screen.svg
next_diff.svg
prev_diff.svg
question.svg
recycle_bin.svg
redo.svg
reject.svg
reorder_columns.svg
save_schema.svg
search.svg
smallbug.svg
sqlite_compare_logo.svg
sqlite_feather.svg
text2451.png
undo.svg
uninstall.svg
v_bullet.svg
using System;
using System.Collections.Generic;
using System.Text;

namespace SQLiteParser
{
    public class SQLiteInExpression : SQLiteExpression
    {
        private SQLiteInExpression()
        {
        }

        public SQLiteInExpression(SQLiteExpression expr, bool isIn, List<SQLiteExpression> exprlist)
        {
            _expr = expr;
            _isIn = isIn;
            _exprlist = exprlist;
        }

        public SQLiteInExpression(SQLiteExpression expr, bool isIn, SQLiteSelectStatement select)
        {
            _expr = expr;
            _isIn = isIn;
            _select = select;
        }

        public SQLiteInExpression(SQLiteExpression expr, bool isIn, SQLiteObjectName table)
        {
            _expr = expr;
            _isIn = isIn;
            _table = table;
        }

        public SQLiteExpression Expression
        {
            get { return _expr; }
            set { _expr = value; }
        }

        public bool In
        {
            get { return _isIn; }
            set { _isIn = value; }
        }

        public List<SQLiteExpression> ExpressionsList
        {
            get { return _exprlist; }
            set { _exprlist = value; }
        }

        public SQLiteSelectStatement SelectStatement
        {
            get { return _select; }
            set { _select = value; }
        }

        public SQLiteObjectName TableName
        {
            get { return _table; }
            set { _table = value; }
        }

        public override bool IsConstant(bool allowNull)
        {
            return false;
        }

        public override bool Equals(object obj)
        {
            if (obj == null)
                return false;

            SQLiteInExpression dst = obj as SQLiteInExpression;
            if (dst == null)
                return false;

            if (_isIn != dst._isIn)
                return false;

            if (!RefCompare.CompareMany(_expr, dst._expr, _select, dst._select, _table, dst._table))
                return false;
            if (!RefCompare.CompareList<SQLiteExpression>(_exprlist, dst._exprlist))
                return false;

            return base.Equals(obj);
        }

        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(_expr.ToString());

            if (_isIn)
                sb.Append(" IN ");
            else
                sb.Append(" NOT IN ");

            if (_exprlist != null)
            {
                // expr in_op LP exprlist RP

                sb.Append("(");
                for (int i = 0; i < _exprlist.Count; i++)
                {
                    sb.Append(_exprlist[i].ToString());
                    if (i < _exprlist.Count - 1)
                        sb.Append(",");
                } // for
                sb.Append(")");
            } // if
            else if (_select != null)
            {
                // expr in_op LP select RP

                sb.Append("(");
                sb.Append(_select.ToString());
                sb.Append(")");
            } // else
            else if (_table != null)
            {
                // expr in_op nm dbnm

                sb.Append(_table.ToString());
            } // else
            else
                throw new ArgumentException("illegal SQLiteInExpression instance");

            return sb.ToString();
        }

        public override object Clone()
        {
            SQLiteExpression expr = null;
            if (_expr != null)
                expr = (SQLiteExpression)_expr.Clone();
            SQLiteSelectStatement select = null;
            if (_select != null)
                select = (SQLiteSelectStatement)_select.Clone();
            SQLiteObjectName table = null;
            if (_table != null)
                table = (SQLiteObjectName)_table.Clone();
            List<SQLiteExpression> exprlist = null;
            if (_exprlist != null)
            {
                exprlist = new List<SQLiteExpression>();
                foreach (SQLiteExpression e in _exprlist)
                    exprlist.Add((SQLiteExpression)e.Clone());
            }

            SQLiteInExpression res = new SQLiteInExpression();
            res._expr = expr;
            res._exprlist = exprlist;
            res._isIn = _isIn;
            res._select = select;
            res._table = table;
            return res;
        }

        private bool _isIn;
        private SQLiteExpression _expr;
        private SQLiteSelectStatement _select;
        private SQLiteObjectName _table;
        private List<SQLiteExpression> _exprlist;
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)

Share

About the Author

liron.levi
Software Developer Arineta Cardio Imaging
Israel Israel
My name is Liron Levi and I'm developing software for fun & profit for 15 years already. I'm now working for Arineta Cardio Imaging as a software developer (the company develops a CT machine).

I can be contacted directly at liron.levi@outlook.com or via linkedin at http://www.linkedin.com/pub/liron-levy/1/578/ab5

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160426.1 | Last Updated 22 Feb 2015
Article Copyright 2011 by liron.levi
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid